本文整理汇总了C++中LocalVector::AddScale方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalVector::AddScale方法的具体用法?C++ LocalVector::AddScale怎么用?C++ LocalVector::AddScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalVector
的用法示例。
在下文中一共展示了LocalVector::AddScale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if(setlssd)
ls.MakeZLSSD(bubmap_ptr, maxbmap); // bubmap must be ready and maxbmap available
#endif
ls.Build();
#ifdef MATDIA
mat.ConvertToDIA();
#endif
gettimeofday(&now, NULL);
tack = now.tv_sec*1000000.0+(now.tv_usec);
b=(tack-tick)/1000000;
std::cout << "Building:" << b << " sec" << std::endl;
mat.info();
gettimeofday(&now, NULL);
tick = now.tv_sec*1000000.0+(now.tv_usec);
ls.Solve(rhs, &x);
gettimeofday(&now, NULL);
tack = now.tv_sec*1000000.0+(now.tv_usec);
s= (tack-tick)/1000000;
std::cout << "Solver execution:" << s << " sec" << std::endl;
std::cout << "Total execution:" << s+b << " sec" << std::endl;
#ifdef GUUS
x.MoveToHost();
sol_norm=x.Norm();
cout<<"\n Norm of Solution is "<<sol_norm<<endl;
cout<<"\n Norm of Reference Solution is "<<refsol.Norm()<<endl;
refones.AddScale(x,(double)-1.0f);
x.AddScale(refsol,(double)-1.0f);
diff_norm=x.Norm();
ones_norm=refones.Norm();
cout<<"\n Relative Norm of Calculated Solution w.r.t. Reference is "<<((double)diff_norm/(double)sol_norm)<<endl;
cout<<"\n Relative Norm of Calculated Solution w.r.t. Ones is "<<((double)ones_norm/(double)sol_norm)<<endl;
#endif
//x.WriteFileASCII("x_solution1e3shell_ilu01.rec");
ls.Clear();
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
std::cout << "-----------------------------------------------" << std::endl;
std::cout << "DPCG solver FSAI" << std::endl;
refones.Ones();
#ifdef GUUS
rhs.ReadFileASCII(std::string(argv[3]));
x.SetRandom(0.0,1.0,1000);
ls.SetZ(Zin);
#endif
#ifdef BUBFLO
x.ReadFileASCII(std::string(argv[2]));
rhs.ReadFileASCII(std::string(argv[3]));
#endif
gettimeofday(&now, NULL);
tick = now.tv_sec*1000000.0+(now.tv_usec);
#ifdef BUBFLO
示例2: main
//.........这里部分代码省略.........
ls.SetZlssd(setlssd);
#endif
gettimeofday(&now, NULL);
tack = now.tv_sec*1000000.0+(now.tv_usec);
lprep=(tack-tick)/1000000;
std::cout << "levelset_prep" << lprep << " sec" << std::endl;
// Linear Solver
// return 0;
gettimeofday(&now, NULL);
tick = now.tv_sec*1000000.0+(now.tv_usec);
#ifdef SCALIN
mat.ExtractInverseDiagonal_sqrt(&Dinvhalf_min, -1);
mat.ExtractInverseDiagonal_sqrt(&Dinvhalf_plus, 1);
mat.DiagonalMatrixMult(Dinvhalf_min);
mat.DiagonalMatrixMult_fromL(Dinvhalf_min);
//x.PointWiseMult(Dinvhalf_plus);
rhs.PointWiseMult(Dinvhalf_min);
// rhs.Scale(0.3);
#endif
#ifdef GUUS
ls.SetZ(Zin);
#endif
ls.SetOperator(mat);
ls.Init(0.0, 1e-6, 1e8, 200000);
// ls.RecordResidualHistory();
#ifdef BUBFLO
ls.MakeZ_CSR(); // requires xdim_ and novecni_ and zlssd_ to be set
if(setlssd)
ls.MakeZLSSD(bubmap_ptr, maxbmap); // bubmap must be ready and maxbmap available
#endif
//
// stop_paralution();
// return 0;
ls.Build();
#ifdef MATDIA
mat.ConvertToDIA();
#endif
gettimeofday(&now, NULL);
tack = now.tv_sec*1000000.0+(now.tv_usec);
b=(tack-tick)/1000000;
std::cout << "Building:" << b+lprep << " sec" << std::endl;
// ls.Verbose(2);
mat.info();
gettimeofday(&now, NULL);
tick = now.tv_sec*1000000.0+(now.tv_usec);
ls.Solve(rhs, &x);
gettimeofday(&now, NULL);
tack = now.tv_sec*1000000.0+(now.tv_usec);
s=(tack-tick)/1000000;
std::cout << "Solver execution:" << s << " sec" << std::endl;
std::cout << "Total execution:" << s+b << " sec" << std::endl;
#ifdef SCALIN
x.PointWiseMult(Dinvhalf_min);
#endif
//
#ifdef GUUS
// x.WriteFileASCII("x_solution_shell_inv_neumann.rec");
//ls.RecordHistory("res__ongpu_tns.rec");
x.MoveToHost();
x.WriteFileASCII("x_neumann.rec");
x.MoveToAccelerator();
sol_norm=x.Norm();
mat.Apply(x, &chk_r);
chk_r.ScaleAdd(double(-1.0), rhs);
cout<<"\n Real Residual Norm is "<<chk_r.Norm();
cout<<"\n Norm of Solution is "<<sol_norm<<endl;
cout<<"\n Norm of Reference Solution is "<<refsol.Norm()<<endl;
cout<<"\n Norm of Ones is "<<refones.Norm()<<endl;
x.MoveToHost();
refones.AddScale(x,(double)-1.0f);
x.AddScale(refsol,(double)-1.0f);
diff_norm=x.Norm();
ones_norm=refones.Norm();
cout<<"\n Relative Norm of Calculated Solution w.r.t. Reference is "<<((double)diff_norm/(double)sol_norm)<<endl;
cout<<"\n Relative Norm of Calculated Solution w.r.t. Ones is "<<((double)ones_norm/(double)sol_norm)<<endl;
#endif
ls.Clear();
stop_paralution();
return 0;
}