本文整理汇总了C++中thyra::LinearOpTester::dump_all方法的典型用法代码示例。如果您正苦于以下问题:C++ LinearOpTester::dump_all方法的具体用法?C++ LinearOpTester::dump_all怎么用?C++ LinearOpTester::dump_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thyra::LinearOpTester
的用法示例。
在下文中一共展示了LinearOpTester::dump_all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Comm
TEUCHOS_UNIT_TEST(tIterativePreconditionerFactory, inverse_test)
{
// build global (or serial communicator)
#ifdef HAVE_MPI
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
Teko::LinearOp A = build2x2(Comm,1,2,3,4);
RCP<Teko::InverseLibrary> invLib = Teko::InverseLibrary::buildFromStratimikos();
RCP<Teko::InverseFactory> invFact = invLib->getInverseFactory("Amesos");
Teko::LinearOp iP = Teko::buildInverse(*invFact,A);
Thyra::LinearOpTester<double> tester;
tester.dump_all(true);
tester.show_all_tests(true);
{
RCP<Teko::InverseFactory> precOpFact = rcp(new Teko::StaticOpInverseFactory(iP));
RCP<Teko::IterativePreconditionerFactory> precFact = rcp(new Teko::IterativePreconditionerFactory(9,precOpFact));
RCP<Teko::InverseFactory> invFact = rcp(new Teko::PreconditionerInverseFactory(precFact,Teuchos::null));
Teko::LinearOp prec = Teko::buildInverse(*invFact,A);
const bool result = tester.compare( *prec, *iP, Teuchos::ptrFromRef(out));
if (!result) {
out << "Apply 0: FAILURE" << std::endl;
success = false;
}
else
out << "Apply 0: SUCCESS" << std::endl;
}
}
示例2:
TEUCHOS_UNIT_TEST(assembly_engine, z_basic_epetra_vtpetra)
{
TEUCHOS_ASSERT(tLinearOp!=Teuchos::null);
TEUCHOS_ASSERT(eLinearOp!=Teuchos::null);
TEUCHOS_ASSERT(tVector!=Teuchos::null);
TEUCHOS_ASSERT(eVector!=Teuchos::null);
Thyra::LinearOpTester<double> tester;
tester.set_all_error_tol(1e-14);
tester.show_all_tests(true);
tester.dump_all(true);
tester.num_random_vectors(200);
{
const bool result = tester.compare( *tLinearOp, *eLinearOp, Teuchos::ptrFromRef(out) );
TEST_ASSERT(result);
}
{
const bool result = Thyra::testRelNormDiffErr(
"Tpetra",*tVector,
"Epetra",*eVector,
"linear_properties_error_tol()", 1e-14,
"linear_properties_warning_tol()", 1e-14,
&out);
TEST_ASSERT(result);
}
}
示例3:
TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test_tpetra)
{
Kokkos::initialize();
// build global (or serial communicator)
RCP<const Teuchos::Comm<int> > Comm = Tpetra::DefaultPlatform::getDefaultPlatform ().getComm ();
Teko::LinearOp A_00 = build2x2(Comm,1,2,3,4);
Teko::LinearOp A_01 = build2x2(Comm,5,6,7,8);
Teko::LinearOp A_02 = build2x2(Comm,9,10,11,12);
Teko::LinearOp A_10 = build2x2(Comm,9,10,11,12);
Teko::LinearOp A_11 = build2x2(Comm,-13,-14,-15,-16);
Teko::LinearOp A_12 = build2x2(Comm,-1,-4,-5,-6);
Teko::LinearOp A_20 = build2x2(Comm,-9,-10,-11,-12);
Teko::LinearOp A_21 = build2x2(Comm,13,14,15,16);
Teko::LinearOp A_22 = build2x2(Comm,1,4,5,6);
Teko::BlockedLinearOp A = Teko::createBlockedOp();
Teko::beginBlockFill(A,3,3);
Teko::setBlock(0,0,A,A_00);
Teko::setBlock(0,1,A,A_01);
Teko::setBlock(0,2,A,A_02);
Teko::setBlock(1,0,A,A_10);
Teko::setBlock(1,1,A,A_11);
Teko::setBlock(1,2,A,A_12);
Teko::setBlock(2,0,A,A_20);
Teko::setBlock(2,1,A,A_21);
Teko::setBlock(2,2,A,A_22);
Teko::endBlockFill(A);
std::string reorderType = "[ [0 1] 2]";
Teuchos::RCP<const Teko::BlockReorderManager> brm = Teko::blockedReorderFromString(reorderType);
Teko::ModifiableLinearOp re_A = Teuchos::rcp_const_cast<Thyra::LinearOpBase<double> >(Teko::buildReorderedLinearOp(*brm,A));
Teko::ModifiableLinearOp final_A = Teuchos::rcp(new Teko::ReorderedLinearOp(brm,re_A));
Thyra::LinearOpTester<double> tester;
tester.dump_all(true);
tester.show_all_tests(true);
{
const bool result = tester.compare( *final_A, *A, Teuchos::ptrFromRef(out));
if (!result) {
out << "Apply: FAILURE" << std::endl;
success = false;
}
else
out << "Apply: SUCCESS" << std::endl;
}
Kokkos::finalize();
}
示例4: Comm
TEUCHOS_UNIT_TEST(tLU2x2InverseOp, exact_test)
{
// build global (or serial communicator)
#ifdef HAVE_MPI
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
Teko::LinearOp A_00 = build2x2(Comm,1,2,3,4);
Teko::LinearOp A_01 = build2x2(Comm,5,6,7,8);
Teko::LinearOp A_10 = build2x2(Comm,9,10,11,12);
Teko::LinearOp A_11 = build2x2(Comm,-13,-14,-15,-16);
Teko::BlockedLinearOp A = Teko::toBlockedLinearOp(Thyra::block2x2(A_00,A_01,A_10,A_11));
Teko::LinearOp S = build2x2(Comm,26.000000000000000, 28.000000000000004, 30.000000000000000, 32.000000000000000);
Teko::LinearOp iA_00 = build2x2(Comm,-1.000000000000000, 0.500000000000000, 0.749999999999998, -0.249999999999998);
Teko::LinearOp iA_01 = build2x2(Comm,-3.000000000000004, 2.500000000000003, 2.750000000000008, -2.250000000000007);
Teko::LinearOp iA_10 = build2x2(Comm,-1.999999999999999, 1.499999999999999, 1.749999999999999, -1.249999999999999);
Teko::LinearOp iA_11 = build2x2(Comm, 4.000000000000001, -3.500000000000001, -3.750000000000001, 3.250000000000001);
Teko::LinearOp iA = Thyra::block2x2(iA_00,iA_01,iA_10,iA_11);
Thyra::LinearOpTester<double> tester;
tester.dump_all(true);
tester.show_all_tests(true);
{
RCP<Teko::InverseLibrary> invLib = Teko::InverseLibrary::buildFromStratimikos();
RCP<Teko::InverseFactory> invFact = invLib->getInverseFactory("Amesos");
Teko::LinearOp invA_00 = Teko::buildInverse(*invFact,A_00);
Teko::LinearOp invS = Teko::buildInverse(*invFact,S);
Teko::LinearOp invA = Teko::createLU2x2InverseOp(A,invA_00,invA_00,invS,"Approximation");
const bool result = tester.compare( *invA, *iA, &out);
if (!result) {
out << "Apply: FAILURE" << std::endl;
success = false;
}
else
out << "Apply: SUCCESS" << std::endl;
}
}
示例5: Comm
TEUCHOS_UNIT_TEST(tProbingFactory, invlib_constr)
{
// build global (or serial communicator)
#ifdef HAVE_MPI
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
Teko::LinearOp lo = buildSystem(Comm,10);
Teuchos::ParameterList subList;
subList.set("Type","Probing Preconditioner");
subList.set("Inverse Type","Amesos");
subList.set("Probing Graph Operator",lo);
Teuchos::ParameterList pl;
pl.set("Prober",subList);
Teuchos::RCP<Teko::InverseLibrary> invLib = Teko::InverseLibrary::buildFromParameterList(pl);
Teuchos::RCP<Teko::InverseFactory> proberFactory = invLib->getInverseFactory("Prober");
Teuchos::RCP<Teko::InverseFactory> directSolveFactory = invLib->getInverseFactory("Amesos");
{
Teko::LinearOp probedInverse = Teko::buildInverse(*proberFactory,lo);
Teko::LinearOp invLo = Teko::buildInverse(*directSolveFactory,lo);
Thyra::LinearOpTester<double> tester;
tester.dump_all(true);
tester.show_all_tests(true);
{
const bool result = tester.compare( *probedInverse, *invLo, &out);
if (!result) {
out << "Apply: FAILURE" << std::endl;
success = false;
}
else
out << "Apply: SUCCESS" << std::endl;
}
}
}
示例6:
TEUCHOS_UNIT_TEST(assembly_engine, z_basic_epetra_vtpetra)
{
PHX::InitializeKokkosDevice();
TEUCHOS_ASSERT(tLinearOp!=Teuchos::null);
TEUCHOS_ASSERT(eLinearOp!=Teuchos::null);
TEUCHOS_ASSERT(tVector!=Teuchos::null);
TEUCHOS_ASSERT(eVector!=Teuchos::null);
Thyra::LinearOpTester<double> tester;
tester.set_all_error_tol(1e-14);
tester.show_all_tests(true);
tester.dump_all(true);
tester.num_random_vectors(200);
{
const bool result = tester.compare( *tLinearOp, *eLinearOp, Teuchos::ptrFromRef(out) );
TEST_ASSERT(result);
}
{
const bool result = Thyra::testRelNormDiffErr(
"Tpetra",*tVector,
"Epetra",*eVector,
"linear_properties_error_tol()", 1e-14,
"linear_properties_warning_tol()", 1e-14,
&out);
TEST_ASSERT(result);
}
// Need to kill global objects so that memory leaks on kokkos ref
// count pointing doesn't trigger test failure.
eLinearOp = Teuchos::null;
tLinearOp = Teuchos::null;
eVector = Teuchos::null;
tVector = Teuchos::null;
PHX::FinalizeKokkosDevice();
}
示例7: ptrFromRef
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( SimpleDenseLinearOp, basic,
Scalar )
{
using Teuchos::rcp_dynamic_cast;
typedef ScalarTraits<Scalar> ST;
const RCP<MultiVectorBase<Scalar> > mv =
createSerialMultiVector<Scalar>(g_dim, g_dim/2, ST::one());
const RCP<LinearOpBase<Scalar> > op =
createNonconstSimpleDenseLinearOp<Scalar>(mv);
TEST_EQUALITY(
mv,
rcp_dynamic_cast<SimpleDenseLinearOp<Scalar> >(op)->getNonconstMultiVector()
);
Thyra::LinearOpTester<Scalar> linearOpTester;
linearOpTester.dump_all(g_dumpAll);
TEST_ASSERT(linearOpTester.check(*op, ptrFromRef(out)));
}
示例8: run_composite_linear_ops_tests
bool run_composite_linear_ops_tests(
const Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> > comm,
const int n,
const bool useSpmd,
const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &tol,
const bool dumpAll,
Teuchos::FancyOStream *out_arg
)
{
using Teuchos::as;
typedef Teuchos::ScalarTraits<Scalar> ST;
typedef typename ST::magnitudeType ScalarMag;
typedef Teuchos::ScalarTraits<ScalarMag> STM;
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::null;
using Teuchos::rcp_const_cast;
using Teuchos::rcp_dynamic_cast;
using Teuchos::dyn_cast;
using Teuchos::OSTab;
using Thyra::relErr;
using Thyra::passfail;
RCP<Teuchos::FancyOStream>
out = rcp(new Teuchos::FancyOStream(rcp(out_arg,false)));
const Teuchos::EVerbosityLevel
verbLevel = dumpAll?Teuchos::VERB_EXTREME:Teuchos::VERB_HIGH;
if (nonnull(out)) *out
<< "\n*** Entering run_composite_linear_ops_tests<"<<ST::name()<<">(...) ...\n";
bool success = true, result;
const ScalarMag warning_tol = ScalarMag(1e-2)*tol, error_tol = tol;
Thyra::LinearOpTester<Scalar> linearOpTester;
linearOpTester.linear_properties_warning_tol(warning_tol);
linearOpTester.linear_properties_error_tol(error_tol);
linearOpTester.adjoint_warning_tol(warning_tol);
linearOpTester.adjoint_error_tol(error_tol);
linearOpTester.dump_all(dumpAll);
Thyra::LinearOpTester<Scalar> symLinearOpTester(linearOpTester);
symLinearOpTester.check_for_symmetry(true);
symLinearOpTester.symmetry_warning_tol(STM::squareroot(warning_tol));
symLinearOpTester.symmetry_error_tol(STM::squareroot(error_tol));
RCP<const Thyra::VectorSpaceBase<Scalar> > space;
if(useSpmd) space = Thyra::defaultSpmdVectorSpace<Scalar>(comm,n,-1);
else space = Thyra::defaultSpmdVectorSpace<Scalar>(n);
if (nonnull(out)) *out
<< "\nUsing a basic vector space described as " << describe(*space,verbLevel) << " ...\n";
if (nonnull(out)) *out << "\nCreating random n x (n/2) multi-vector origA ...\n";
RCP<Thyra::MultiVectorBase<Scalar> >
mvOrigA = createMembers(space,n/2,"origA");
Thyra::seed_randomize<Scalar>(0);
//RTOpPack::show_spmd_apply_op_dump = true;
Thyra::randomize( as<Scalar>(as<Scalar>(-1)*ST::one()), as<Scalar>(as<Scalar>(+1)*ST::one()),
mvOrigA.ptr() );
RCP<const Thyra::LinearOpBase<Scalar> >
origA = mvOrigA;
if (nonnull(out)) *out << "\norigA =\n" << describe(*origA,verbLevel);
//RTOpPack::show_spmd_apply_op_dump = false;
if (nonnull(out)) *out << "\nTesting origA ...\n";
Thyra::seed_randomize<Scalar>(0);
result = linearOpTester.check(*origA, out.ptr());
if(!result) success = false;
if (nonnull(out)) *out
<< "\nCreating implicit scaled linear operator A1 = scale(0.5,origA) ...\n";
RCP<const Thyra::LinearOpBase<Scalar> >
A1 = scale(as<Scalar>(0.5),origA);
if (nonnull(out)) *out << "\nA1 =\n" << describe(*A1,verbLevel);
if (nonnull(out)) *out << "\nTesting A1 ...\n";
Thyra::seed_randomize<Scalar>(0);
result = linearOpTester.check(*A1,out.ptr());
if(!result) success = false;
if (nonnull(out)) *out << "\nTesting that A1.getOp() == origA ...\n";
Thyra::seed_randomize<Scalar>(0);
result = linearOpTester.compare(
*dyn_cast<const Thyra::DefaultScaledAdjointLinearOp<Scalar> >(*A1).getOp(),
*origA,out.ptr());
if(!result) success = false;
{
if (nonnull(out)) *out
<< "\nUnwrapping origA to get non-persisting pointer to origA_1, scalar and transp ...\n";
Scalar scalar;
Thyra::EOpTransp transp;
const Thyra::LinearOpBase<Scalar> *origA_1 = NULL;
unwrap( *origA, &scalar, &transp, &origA_1 );
TEUCHOS_TEST_FOR_EXCEPT( origA_1 == NULL );
if (nonnull(out)) *out << "\nscalar = " << scalar << " == 1 ? ";
result = (scalar == ST::one());
//.........这里部分代码省略.........
示例9: 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;
}