本文整理汇总了C++中LocalVector::CloneBackend方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalVector::CloneBackend方法的具体用法?C++ LocalVector::CloneBackend怎么用?C++ LocalVector::CloneBackend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalVector
的用法示例。
在下文中一共展示了LocalVector::CloneBackend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
}
// get lambda max (Rayleigh quotient)
mat.Apply(*b_k, b_k1);
plambda_max = b_k1->Dot(*b_k) ;
tack = paralution_time();
std::cout << "Power method (lambda max) execution:" << (tack-tick)/1000000 << " sec" << std::endl;
mat.AddScalarDiagonal(double(-1.0)*plambda_max);
b_k->Ones();
tick = paralution_time();
// compute lambda min
for (int i=0; i<=iter_max; ++i) {
mat.Apply(*b_k, b_k1);
// std::cout << b_k1->Dot(*b_k) + plambda_max << std::endl;
b_k1->Scale(double(1.0)/b_k1->Norm());
b_tmp = b_k1;
b_k1 = b_k;
b_k = b_tmp;
}
// get lambda min (Rayleigh quotient)
mat.Apply(*b_k, b_k1);
plambda_min = (b_k1->Dot(*b_k) + plambda_max);
// back to the original matrix
mat.AddScalarDiagonal(plambda_max);
tack = paralution_time();
std::cout << "Power method (lambda min) execution:" << (tack-tick)/1000000 << " sec" << std::endl;
std::cout << "Power method Lambda min = " << plambda_min
<< "; Lambda max = " << plambda_max
<< "; iter=2x" << iter_max << std::endl;
LocalVector<double> x;
LocalVector<double> rhs;
x.CloneBackend(mat);
rhs.CloneBackend(mat);
x.Allocate("x", mat.get_nrow());
rhs.Allocate("rhs", mat.get_nrow());
// Chebyshev iteration
Chebyshev<LocalMatrix<double>, LocalVector<double>, double > ls;
rhs.Ones();
x.Zeros();
ls.SetOperator(mat);
ls.Set(plambda_min, plambda_max);
ls.Build();
tick = paralution_time();
ls.Solve(rhs, &x);
tack = paralution_time();
std::cout << "Solver execution:" << (tack-tick)/1000000 << " sec" << std::endl;
// PCG + Chebyshev polynomial
CG<LocalMatrix<double>, LocalVector<double>, double > cg;
AIChebyshev<LocalMatrix<double>, LocalVector<double>, double > p;
// damping factor
plambda_min = plambda_max / 7;
p.Set(3, plambda_min, plambda_max);
rhs.Ones();
x.Zeros();
cg.SetOperator(mat);
cg.SetPreconditioner(p);
cg.Build();
tick = paralution_time();
cg.Solve(rhs, &x);
tack = paralution_time();
std::cout << "Solver execution:" << (tack-tick)/1000000 << " sec" << std::endl;
stop_paralution();
return 0;
}