本文整理汇总了C++中Epetra_Vector::ExtractView方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_Vector::ExtractView方法的具体用法?C++ Epetra_Vector::ExtractView怎么用?C++ Epetra_Vector::ExtractView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_Vector
的用法示例。
在下文中一共展示了Epetra_Vector::ExtractView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//EpetraVector_To_TpetraVectorNonConst: copies Epetra_Vector to non-const Tpetra_Vector
Teuchos::RCP<Tpetra_Vector> Petra::EpetraVector_To_TpetraVectorNonConst(const Epetra_Vector& epetraVector_,
const Teuchos::RCP<const Teuchos::Comm<int> >& commT_)
{
//get map from epetraVector_ and convert to Tpetra::Map
auto mapT = EpetraMap_To_TpetraMap(epetraVector_.Map(), commT_);
ST *values;
epetraVector_.ExtractView(&values);
Teuchos::ArrayView<ST> valuesAV = Teuchos::arrayView(values, mapT->getNodeNumElements());
Teuchos::RCP<Tpetra_Vector> tpetraVector_ = Teuchos::rcp(new Tpetra_Vector(mapT, valuesAV));
return tpetraVector_;
}
示例2: RightScale
//=============================================================================
int Epetra_PETScAIJMatrix::RightScale(const Epetra_Vector& X) {
//
// This function scales the jth row of A by x[j].
//
double *xptr;
X.ExtractView(&xptr);
Vec petscX;
# ifdef HAVE_MPI
int ierr=VecCreateMPIWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptr,&petscX); CHKERRQ(ierr);
# else //FIXME untested
int ierr=VecCreateSeqWithArray(Comm_->Comm(),X.MyLength(),X.GlobalLength(),xptr,&petscX); CHKERRQ(ierr);
# endif
MatDiagonalScale(Amat_, PETSC_NULL, petscX);
ierr=VecDestroy(petscX); CHKERRQ(ierr);
return(0);
} //RightScale()
示例3: test_azoo_scaling
int test_azoo_scaling(Epetra_CrsMatrix& A,
Epetra_Vector& x,
Epetra_Vector& b,
bool verbose)
{
Epetra_Vector vec1(x);
Epetra_Vector vec2(x);
Epetra_Vector diag(x);
Epetra_Vector vec3(x);
Epetra_Vector vec4(x);
Epetra_Vector rhs(x);
Epetra_Vector soln_none(x);
Epetra_Vector soln_jacobi(x);
Epetra_Vector soln_rowsum(x);
Epetra_Vector soln_symdiag(x);
vec1.PutScalar(1.0);
A.Multiply(false, vec1, vec2);
A.ExtractDiagonalCopy(diag);
double* diag_vals = NULL;
diag.ExtractView(&diag_vals);
int* options = new int[AZ_OPTIONS_SIZE];
double* params = new double[AZ_PARAMS_SIZE];
AZ_defaults(options, params);
options[AZ_output] = verbose ? 1 : AZ_none;
options[AZ_scaling] = AZ_Jacobi;
AztecOO::MatrixData mdata(&A);
AZ_MATRIX* Amat = AZ_matrix_create(vec1.Map().NumMyElements());
AZ_set_MATFREE(Amat, (void*)(&mdata), Epetra_Aztec_matvec);
AZ_SCALING* scaling = AZ_scaling_create();
double* xvals = NULL, *bvals = NULL;
x.ExtractView(&xvals);
b.ExtractView(&bvals);
int err = AztecOO_scale_epetra(AZ_SCALE_MAT_RHS_SOL, Amat,
options, bvals, xvals, NULL, scaling);
if (err != 0) {
if (verbose) {
cout << "AztecOO_scale_epetra returned err="<<err<<endl;
}
return(err);
}
A.Multiply(false, vec1, vec3);
vec4.Multiply(1.0, diag, vec3, 0.0);
double vec2nrm, vec4nrm;
vec2.Norm2(&vec2nrm);
vec4.Norm2(&vec4nrm);
if (fabs(vec2nrm - vec4nrm) > 1.e-6) {
return(-1);
}
//now call the scaling function again, just to allow for
//testing memory-leak issues.
err = AztecOO_scale_epetra(AZ_SCALE_MAT_RHS_SOL, Amat,
options, bvals, xvals, NULL, scaling);
if (err != 0) {
if (verbose) {
cout << "AztecOO_scale_epetra returned err="<<err<<endl;
}
return(err);
}
AztecOO_scale_epetra(AZ_DESTROY_SCALING_DATA, Amat, options,
bvals, xvals, NULL, scaling);
x.PutScalar(1.0);
Epetra_CrsMatrix* Atmp = create_and_fill_crs_matrix(A.RowMap());
Atmp->Multiply(false, x, rhs);
x.PutScalar(0.0);
AztecOO azoo(&A, &x, &b);
azoo.SetAztecOption(AZ_scaling, AZ_Jacobi);
if (verbose) {
azoo.SetAztecOption(AZ_output, 1);
}
else {
azoo.SetAztecOption(AZ_output, AZ_none);
}
azoo.Iterate(100, 1.e-6);
delete Atmp;
Epetra_CrsMatrix* Atmp1 = create_and_fill_crs_matrix(A.RowMap());
//.........这里部分代码省略.........