本文整理汇总了C++中LocalVector::PointWiseMult方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalVector::PointWiseMult方法的具体用法?C++ LocalVector::PointWiseMult怎么用?C++ LocalVector::PointWiseMult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalVector
的用法示例。
在下文中一共展示了LocalVector::PointWiseMult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
if (argc == 1) {
std::cerr << argv[0] << " <matrix> <initial_guess> <rhs> [Num threads]" << std::endl;
exit(1);
}
init_paralution();
// if (argc > 4) {
// set_omp_threads_paralution(atoi(argv[]));
// }
set_omp_threads_paralution(8);
info_paralution();
struct timeval now;
double tick, tack, b,s, sol_norm, diff_norm, ones_norm;
double *phi_ptr=NULL;
int *bubmap_ptr=NULL, phisize, maxbmap, setlssd, lvst_offst;
int xdim, ydim, zdim, defvex_perdirec;
#ifdef BUBFLO
xdim=atoi(argv[5]);
setlssd=atoi(argv[6]);
defvex_perdirec=atoi(argv[7]);
lvst_offst=atoi(argv[8]);
phisize=(xdim+2*lvst_offst)*(ydim+2*lvst_offst)*(zdim+2*lvst_offst);
#endif
LocalVector<double> x;
LocalVector<double> rhs;
LocalMatrix<double> mat;
LocalVector<double> Dinvhalf_min;
LocalVector<double> Dinvhalf_plus;
#ifdef GUUS
LocalMatrix<double> Zin;
LocalVector<double> refsol;
LocalVector<double> refones;
#endif
mat.ReadFileMTX(std::string(argv[1]));
mat.info();
#ifdef GUUS
Zin.ReadFileMTX(std::string(argv[2]));
Zin.info();
refsol.Allocate("refsol", mat.get_nrow());
refones.Allocate("refones", mat.get_nrow());
//refsol.Ones();
refsol.ReadFileASCII(std::string(argv[4]));
refones.Ones();
#endif
x.Allocate("x", mat.get_nrow());
rhs.Allocate("rhs", mat.get_nrow());
// Linear Solver
DPCG<LocalMatrix<double>, LocalVector<double>, double > ls;
MultiElimination<LocalMatrix<double>, LocalVector<double>, double > p;
Jacobi<LocalMatrix<double>, LocalVector<double>, double > j_p;
MultiColoredILU<LocalMatrix<double>, LocalVector<double>, double > mcilu_p;
ILU<LocalMatrix<double>, LocalVector<double>, double > ilu_p;
MultiColoredSGS<LocalMatrix<double>, LocalVector<double>, double > mcsgs_p;
FSAI<LocalMatrix <double>, LocalVector<double>, double > fsai_p ;
SPAI<LocalMatrix <double>, LocalVector <double>, double > spai_p ;
#ifdef GPURUN
mat.MoveToAccelerator();
x.MoveToAccelerator();
rhs.MoveToAccelerator();
#endif
#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);
#endif
/////////////////////////////////////////////////////////////////
std::cout << "-----------------------------------------------" << std::endl;
std::cout << "DPCG solver MCSGS" << std::endl;
#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
//.........这里部分代码省略.........
bubmap.LeaveDataPtr(&bubmap_ptr);
phi.LeaveDataPtr(&phi_ptr);
bubmap_create(phi_ptr, bubmap_ptr, xdim, xdim, xdim, mat.get_nrow(), &maxbmap, lvst_offst);
phi.Clear();
}
ls.Setxdim(xdim);
ls.SetNVectors_eachdirec(defvex_perdirec+1, defvex_perdirec+2, defvex_perdirec+3);
ls.Set_alldims(xdim, xdim, xdim);
ls.Setlvst_offst(lvst_offst);
ls.SetNVectors(defvex_perdirec);
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();