本文整理汇总了C++中TMatrix::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ TMatrix::resize方法的具体用法?C++ TMatrix::resize怎么用?C++ TMatrix::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMatrix
的用法示例。
在下文中一共展示了TMatrix::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: k_extract
void k_extract(const typename EigenType<T, D>::EigenvalueType& eigen_values,
const typename EigenType<T, D>::EigenvectorsType& eigen_vectors,
TMatrix& Q, TMatrix& S, int K)
{
size_t eigen_num = eigen_values.rows();
typename std::vector<typename EigenValue<T> > ev;
for (size_t i = 0; i < eigen_num; i ++)
{
typename std::complex<T> cv = eigen_values(i);
typename EigenValue<T> i_ev(cv.real(), i);
ev.push_back(i_ev);
}
std::sort(ev.begin(), ev.end(), EigenValue<T>());
int gm = eigen_vectors.rows();
Q.resize(gm, K);
TVector s(K);
for (size_t i = 0; i < K; i ++)
{
s(i) = ev[i]._value;
typename MatrixType<std::complex<T>, D>::Matrix q_ci = eigen_vectors.col(ev[i]._idx);
for (size_t j = 0, j_end = q_ci.rows(); j < j_end; j ++)
{
Q(j, i) = q_ci(j).real();
}
}
S = s.asDiagonal();
}
示例2: K81_random_edge_bio_length
// Random biologically meaningful K81 transition matrix with given length.
// Here biologically meaningful means that diagonal entries are maximal in the column they belong to (and the row in this case)
// ( Chang's DLC condition).
void K81_random_edge_bio_length(double len, TMatrix &tm) {
TMatrix tmaux;
long i0, i;
tmaux.resize(4);
for(i=0; i < 4; i++) {
tmaux[i].resize(4);
}
K81_random_edge_length(len, tmaux);
// Permute with the row that starts with the largest entry in column.
// All 4 possible permutations have det = 1
i0 = max_in_col(tmaux, 0);
K81_matrix(tmaux[i0][0], tmaux[i0][1], tmaux[i0][2], tmaux[i0][3], tm);
}
示例3: Initialization
int Initialization(TMatrix input, TVariables output, unsigned int minFeatures){
n = input.size(); if (n == 0){return -1;} // number of points
if (output.size() != n){return -1;}
d = input[0].size(); if (d == 0){return -1;} // space dimension
if (minFeatures == 0 || minFeatures > 2){return -1;}else{numStartFeatures = minFeatures;}
/* Filling static variables x and y with input and output (transposing x) */
x.resize(d);
for (unsigned int i = 0; i < d; i++){
x[i] = TPoint(n);
for (unsigned int j = 0; j < n; j++){
x[i][j] = input[j][i];
}
}
y.resize(n); numLess = 0; numMore = 0;
difference = 0;
for (unsigned int i = 0; i < n; i++){
y[i] = output[i];
difference += y[i];
if (y[i] > 0){numMore++;}else{numLess++;}
}
return 0;
}