本文整理汇总了C++中teuchos::RefCountPtr::LHS方法的典型用法代码示例。如果您正苦于以下问题:C++ RefCountPtr::LHS方法的具体用法?C++ RefCountPtr::LHS怎么用?C++ RefCountPtr::LHS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RefCountPtr
的用法示例。
在下文中一共展示了RefCountPtr::LHS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestContainer
// ======================================================================
bool TestContainer(std::string Type, const Teuchos::RefCountPtr<Epetra_RowMatrix>& A)
{
using std::cout;
using std::endl;
int NumVectors = 3;
int NumMyRows = A->NumMyRows();
Epetra_MultiVector LHS_exact(A->RowMatrixRowMap(), NumVectors);
Epetra_MultiVector LHS(A->RowMatrixRowMap(), NumVectors);
Epetra_MultiVector RHS(A->RowMatrixRowMap(), NumVectors);
LHS_exact.Random(); LHS.PutScalar(0.0);
A->Multiply(false, LHS_exact, RHS);
Epetra_LinearProblem Problem(&*A, &LHS, &RHS);
if (verbose) {
cout << "Container type = " << Type << endl;
cout << "NumMyRows = " << NumMyRows << ", NumVectors = " << NumVectors << endl;
}
LHS.PutScalar(0.0);
Teuchos::RefCountPtr<Ifpack_Container> Container;
if (Type == "dense")
Container = Teuchos::rcp( new Ifpack_DenseContainer(A->NumMyRows(), NumVectors) );
else
Container = Teuchos::rcp( new Ifpack_SparseContainer<Ifpack_Amesos>(A->NumMyRows(), NumVectors) );
assert (Container != Teuchos::null);
IFPACK_CHK_ERR(Container->Initialize());
// set as ID all the local rows of A
for (int i = 0 ; i < A->NumMyRows() ; ++i)
Container->ID(i) = i;
// extract submatrix (in this case, the entire matrix)
// and complete setup
IFPACK_CHK_ERR(Container->Compute(*A));
// set the RHS and LHS
for (int i = 0 ; i < A->NumMyRows() ; ++i)
for (int j = 0 ; j < NumVectors ; ++j) {
Container->RHS(i,j) = RHS[j][i];
Container->LHS(i,j) = LHS[j][i];
}
// set parameters (empty for dense containers)
Teuchos::ParameterList List;
List.set("amesos: solver type", Type);
IFPACK_CHK_ERR(Container->SetParameters(List));
// solve the linear system
IFPACK_CHK_ERR(Container->ApplyInverse());
// get the computed solution, store it in LHS
for (int i = 0 ; i < A->NumMyRows() ; ++i)
for (int j = 0 ; j < NumVectors ; ++j) {
LHS[j][i] = Container->LHS(i,j);
}
double residual = Galeri::ComputeNorm(&LHS, &LHS_exact);
if (A->Comm().MyPID() == 0 && verbose) {
cout << "||x_exact - x||_2 = " << residual << endl;
cout << *Container;
}
bool passed = false;
if (residual < 1e-5)
passed = true;
return(passed);
}