本文整理汇总了C++中SymmetricMatrix::Ncols方法的典型用法代码示例。如果您正苦于以下问题:C++ SymmetricMatrix::Ncols方法的具体用法?C++ SymmetricMatrix::Ncols怎么用?C++ SymmetricMatrix::Ncols使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymmetricMatrix
的用法示例。
在下文中一共展示了SymmetricMatrix::Ncols方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normalizeSum
void SpectClust::normalizeSum(SymmetricMatrix &A) {
RowVector Ones(A.Ncols());
Ones = 1.0;
// Calculate the sum of each row matrix style. Could this be a Diagonal Matrix instead?
Matrix RowSum = Ones * (A.t());
DiagonalMatrix D(A.Ncols());
D = 0;
// Take the inverse square root
for(int i = 1; i <= A.Ncols(); i++) {
D(i,i) = 1/sqrt(RowSum(1,i));
}
Matrix X = D * (A * D);
A << X;
}
示例2: Print
void Print(const SymmetricMatrix& X)
{
++PCN;
cout << "\nMatrix type: " << X.Type().Value() << " (";
cout << X.Nrows() << ", ";
cout << X.Ncols() << ")\n\n";
if (X.IsZero()) { cout << "All elements are zero\n" << flush; return; }
int nr=X.Nrows(); int nc=X.Ncols();
for (int i=1; i<=nr; i++)
{
int j;
for (j=1; j<i; j++) cout << X(j,i) << "\t";
for (j=i; j<=nc; j++) cout << X(i,j) << "\t";
cout << "\n";
}
cout << flush; ++PCZ;
}
示例3: findNLargestSymEvals
bool SpectClust::findNLargestSymEvals(const SymmetricMatrix &W, int numLamda, std::vector<Numeric> &eVals, Matrix &EVec) {
bool converged = false;
eVals.clear();
eVals.reserve(numLamda);
DiagonalMatrix D(W.Ncols());
Matrix E;
try {
EigenValues(W, D, E);
converged = true;
EVec.ReSize(W.Ncols(), numLamda);
int count = 0;
for(int i = W.Ncols(); i > W.Ncols() - numLamda; i--) {
eVals.push_back(D(i));
EVec.Column(++count) << E.Column(i);
}
}
catch(const Exception &e) {
Err::errAbort("Exception: " + ToStr(e.what()));
}
catch(...) {
Err::errAbort("Yikes couldn't calculate eigen vectors.");
}
return converged;
}