本文整理汇总了C++中LocalVector::CopyToData方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalVector::CopyToData方法的具体用法?C++ LocalVector::CopyToData怎么用?C++ LocalVector::CopyToData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalVector
的用法示例。
在下文中一共展示了LocalVector::CopyToData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPUsolveCSRDouble
extern "C" __declspec(dllexport) void CPUsolveCSRDouble(int *row_offset, int *col, double *val,
const int nnz, const int N, double *_rhs, double *_x) {
std::string name = "s";
LocalVector<double> x;
LocalVector<double> rhs;
LocalMatrix<double> mat;
x.Allocate(name, N);
x.Zeros();
rhs.Allocate(name, N);
mat.AllocateCSR(name, nnz, N, N);
mat.CopyFromCSR(row_offset, col, val);
rhs.CopyFromData(_rhs);
CG<LocalMatrix<double>, LocalVector<double>, double> ls;
Jacobi<LocalMatrix<double>, LocalVector<double>, double> p;
ls.SetOperator(mat);
ls.SetPreconditioner(p);
ls.Build();
ls.Solve(rhs, &x);
x.CopyToData(_x);
mat.Clear();
x.Clear();
rhs.Clear();
ls.Clear();
}
示例2: solveCSRSingle
extern "C" __declspec(dllexport) void solveCSRSingle(int *row_offset, int *col, float *val,
const int nnz, const int N, float *_rhs, float *_x) {
std::string name = "s";
LocalVector<float> x;
LocalVector<float> rhs;
LocalMatrix<float> mat;
x.Allocate(name, N);
x.Zeros();
rhs.Allocate(name, N);
mat.AllocateCSR(name, nnz, N, N);
mat.CopyFromCSR(row_offset, col, val);
rhs.CopyFromData(_rhs);
// mat.Check();
/* rhs.SetDataPtr(&_rhs, name, N);
x.SetDataPtr(&_x, name, N);
mat.SetDataPtrCSR(&row_offset, &col, &val, name, nnz, N, N);
*/
mat.MoveToAccelerator();
x.MoveToAccelerator();
rhs.MoveToAccelerator();
CG<LocalMatrix<float>, LocalVector<float>, float> ls;
MultiColoredILU<LocalMatrix<float>, LocalVector<float>, float> p;
ls.SetOperator(mat);
ls.SetPreconditioner(p);
ls.Build();
ls.Solve(rhs, &x);
mat.MoveToHost();
x.MoveToHost();
rhs.MoveToHost();
/*
mat.LeaveDataPtrCSR(&row_offset, &col, &val);
rhs.LeaveDataPtr(&_rhs);
x.LeaveDataPtr(&_x);
*/
x.CopyToData(_x);
mat.Clear();
x.Clear();
rhs.Clear();
ls.Clear();
}