本文整理汇总了C++中SparseVector::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseVector::rows方法的具体用法?C++ SparseVector::rows怎么用?C++ SparseVector::rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseVector
的用法示例。
在下文中一共展示了SparseVector::rows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r
SparseVector<double> SparseSolverEigenCustom::cgSolveSparse(const SparseMatrix<double> & A,const SparseVector<double> & b,int iter, double residual)
{
SparseVector<double> r(b.rows());
SparseVector<double> p(b.rows());
SparseVector<double> Ap(b.rows());
SparseVector<double> x(b.rows());
r = b - A *x;
p = r;
double rTr,pTAp,alpha,beta,rTrnew,rnorm;
SparseVector<double> vtemp;
bool isConverged = false;
for(int k=0;k<iter;k++)
{
Ap = A*p;
vtemp = r.transpose()*r;
rTr = vtemp.coeff(0);
vtemp = p.transpose()*Ap;
pTAp = vtemp.coeff(0);
alpha = rTr/pTAp;
x = x + (alpha * p);
r = r - (alpha * Ap);
rnorm = r.norm();
if(rnorm<residual)
{
isConverged = true;
break;
}
vtemp = r.transpose()*r;
rTrnew = vtemp.coeff(0);
beta = rTrnew / rTr;
p = r + (beta * p);
}
return x;
}
开发者ID:tusharuiit,项目名称:2014-2015_HiwiMedicalXTTVisualization,代码行数:41,代码来源:SparseSolverEigenCustom.cpp