本文整理汇总了C++中thyra::LinearOpTester::check_adjoint方法的典型用法代码示例。如果您正苦于以下问题:C++ LinearOpTester::check_adjoint方法的具体用法?C++ LinearOpTester::check_adjoint怎么用?C++ LinearOpTester::check_adjoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thyra::LinearOpTester
的用法示例。
在下文中一共展示了LinearOpTester::check_adjoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exampleImplicitlyComposedLinearOperators
//.........这里部分代码省略.........
E = mvE,
F = mvF,
J = mvJ,
K = mvK,
L = mvL,
N = mvN,
P = mvP,
Q = mvQ;
out << describe(*A, verbLevel);
out << describe(*B, verbLevel);
out << describe(*C, verbLevel);
out << describe(*E, verbLevel);
out << describe(*F, verbLevel);
out << describe(*J, verbLevel);
out << describe(*K, verbLevel);
out << describe(*L, verbLevel);
out << describe(*N, verbLevel);
out << describe(*P, verbLevel);
out << describe(*Q, verbLevel);
//
// B) Create the composed linear operators
//
// I
const RCP<const LinearOpBase<Scalar> > I = identity(space1, "I");
// D = diag(d)
const RCP<const LinearOpBase<Scalar> > D = diagonal(d, "D");
// M00 = [ gama*B*A + C, E + F ] ^H
// [ J^H * A, I ]
const RCP<const LinearOpBase<Scalar> > M00 =
adjoint(
block2x2(
add( scale(gamma,multiply(B,A)), C ), add( E, F ),
multiply(adjoint(J),A), I
),
"M00"
);
out << "\nM00 = " << describe(*M00, verbLevel);
// M01 = beta * [ Q ]
// [ K ]
const RCP<const LinearOpBase<Scalar> > M01 =
scale(
beta,
block2x1( Q, K ),
"M01"
);
out << "\nM01 = " << describe(*M01, verbLevel);
// M10 = [ L * N^H, eta*P ]
const RCP<const LinearOpBase<Scalar> > M10 =
block1x2(
multiply(L,adjoint(N)), scale(eta,P),
"M10"
);
out << "\nM10 = " << describe(*M10, verbLevel);
// M11 = D - Q^H*Q
const RCP<const LinearOpBase<Scalar> > M11 =
subtract( D, multiply(adjoint(Q),Q), "M11" );
out << "\nM11 = " << describe(*M11, verbLevel);
// M = [ M00, M01 ]
// [ M10, M11 ]
const RCP<const LinearOpBase<Scalar> > M =
block2x2(
M00, M01,
M10, M11,
"M"
);
out << "\nM = " << describe(*M, verbLevel);
//
// C) Test the final composed operator
//
Thyra::LinearOpTester<Scalar> linearOpTester;
linearOpTester.set_all_error_tol(errorTol);
linearOpTester.check_adjoint(testAdjoint);
if (as<int>(verbLevel) >= as<int>(Teuchos::VERB_HIGH))
linearOpTester.show_all_tests(true);
if (as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME))
linearOpTester.dump_all(true);
const bool result = linearOpTester.check(*M,&out);
return result;
}
示例2: main
//.........这里部分代码省略.........
#endif
const LinearOpPtr A = readEpetraCrsMatrixFromMatrixMarketAsLinearOp(
matrixFile, comm, "A");
*out << "\nA = " << describe(*A,verbLevel) << "\n";
const RCP<ParameterList> paramList = getParametersFromXmlFile(paramListFile);
if (showParams) {
*out << "\nRead in parameter list:\n\n";
paramList->print(*out, PLPrintOptions().indent(2).showTypes(true));
}
//
*out << "\nB) Get the preconditioner as a forward solver\n";
//
const RCP<ParameterList> precParamList = sublist(paramList, "Preconditioner Solver");
Stratimikos::DefaultLinearSolverBuilder precSolverBuilder;
precSolverBuilder.setParameterList(precParamList);
const RCP<const Thyra::LinearOpWithSolveFactoryBase<double> > precSolverStrategy
= createLinearSolveStrategy(precSolverBuilder);
//precSolverStrategy->setVerbLevel(verbLevel);
const LinearOpPtr A_inv_prec = inverse<double>(*precSolverStrategy, A,
Thyra::SUPPORT_SOLVE_FORWARD_ONLY,
Teuchos::null, // Use internal solve criteria
Thyra::IGNORE_SOLVE_FAILURE // Ignore solve failures since this is just a prec
);
*out << "\nA_inv_prec = " << describe(*A_inv_prec, verbLevel) << "\n";
if (testPrecIsLinearOp) {
*out << "\nTest that the preconditioner A_inv_prec is indeed a linear operator.\n";
Thyra::LinearOpTester<double> linearOpTester;
linearOpTester.check_adjoint(false);
const bool linearOpCheck = linearOpTester.check(*A_inv_prec, out.ptr());
if (!linearOpCheck) {
success = false;
}
}
//
*out << "\nC) Create the forward solver using the created preconditioner ...\n";
//
const RCP<ParameterList> fwdSolverParamList = sublist(paramList, "Forward Solver");
Stratimikos::DefaultLinearSolverBuilder fwdSolverSolverBuilder;
fwdSolverSolverBuilder.setParameterList(fwdSolverParamList);
const RCP<const Thyra::LinearOpWithSolveFactoryBase<double> > fwdSolverSolverStrategy
= createLinearSolveStrategy(fwdSolverSolverBuilder);
const RCP<Thyra::LinearOpWithSolveBase<double> >
A_lows = fwdSolverSolverStrategy->createOp();
initializePreconditionedOp<double>( *fwdSolverSolverStrategy, A,
unspecifiedPrec(A_inv_prec), A_lows.ptr());
//A_lows->setVerbLevel(verbLevel);
*out << "\nA_lows = " << describe(*A_lows, verbLevel) << "\n";
//
*out << "\nD) Solve the linear system for a random RHS ...\n";
//
VectorPtr x = createMember(A->domain());
VectorPtr b = createMember(A->range());
Thyra::randomize(-1.0, +1.0, b.ptr());
Thyra::assign(x.ptr(), 0.0); // Must give an initial guess!