10 #ifndef THYRA_VECTOR_TESTER_HPP
11 #define THYRA_VECTOR_TESTER_HPP
13 #include "Thyra_VectorTester_decl.hpp"
14 #include "Thyra_VectorStdOps.hpp"
15 #include "Thyra_VectorBase.hpp"
16 #include "Thyra_VectorSpaceBase.hpp"
17 #include "Thyra_TestingTools.hpp"
18 #include "Teuchos_VerbosityLevel.hpp"
24 template<
class Scalar>
28 ,
const int num_random_vectors_in
29 ,
const bool show_all_tests_in
30 ,
const bool dump_all_in
32 :warning_tol_(warning_tol_in)
33 ,error_tol_(error_tol_in)
34 ,num_random_vectors_(num_random_vectors_in)
35 ,show_all_tests_(show_all_tests_in)
36 ,dump_all_(dump_all_in)
40 template<
class Scalar>
48 using Teuchos::describe;
57 OSTab tab(out,1,
"THYRA");
59 bool result, success =
true;
61 if(out.
get()) *out <<endl<<
"*** Entering Thyra::VectorTester<"<<ST::name()<<
">::check(v,...) ...\n";
63 if(out.
get()) *out <<endl<<
"Testing a VectorBase object described as:\n" << describe(v,verbLevel);
65 if(out.
get()) *out <<endl<<
"A) Creating temporary vector t1, t2, t3, and t4 from v.space() ...\n";
69 t1 = createMember(vs), t2 = createMember(vs), t3 = createMember(vs), t4 = createMember(vs);
71 if(out.
get()) *out <<endl<<
"B) Testing VectorBase::applyOp(...) by calling a few standard RTOp operations ... ";
76 three = Scalar(3)*one;
79 using Teuchos::inoutArg;
84 bool these_results =
true;
86 *testOut <<endl<<
"assign(t1.ptr(),2.0) ...\n";
87 Thyra::assign( t1.
ptr(), two );
88 if(dump_all()) *testOut <<endl<<
"\nt1 =\n" << describe(*t1,verbLevel);
90 result = Teuchos::testRelErr<Scalar>(
91 "sum(t1)", sum(*t1),
"2*vs->dim()", two*Scalar(vs->dim()),
92 "error_tol()", error_tol(),
"warning_tol()", warning_tol(),
95 if(!result) these_results =
false;
97 *testOut <<endl<<
"assign(t2.ptr(),3.0) ...\n";
98 Thyra::assign( t2.ptr(), three );
99 if(dump_all()) *testOut <<endl<<
"t2 =\n" << *t1;
101 result = Teuchos::testRelErr<Scalar>(
102 "sum(t2)",sum(*t2),
"3*vs->dim()",three*Scalar(vs->dim()),
103 "error_tol()",error_tol(),
"warning_tol()",warning_tol(),
106 if(!result) these_results =
false;
108 result = Teuchos::testRelErr<Scalar>(
109 "vs->scalarProd(*t1,*t2)",vs->scalarProd(*t1,*t2),
"2*3*vs->dim()",two*three*Scalar(vs->dim()),
110 "error_tol()",error_tol(),
"warning_tol()",warning_tol(),
113 if(!result) these_results =
false;
121 if(out.
get()) *out <<endl<<
"C) Checking the MultiVectorBase interface of v ...\n";
122 result = multiVectorTester_.check(v, out.
ptr());
123 if(!result) success =
false;
125 if(out.
get()) *out <<endl<<
"*** Leaving Thyra::VectorTester<"<<ST::name()<<
">::check(v,...) ...\n";
135 #endif // THYRA_VECTOR_TESTER_HPP
Control printing of test results.
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
basic_OSTab< char > OSTab
basic_FancyOStream< char > FancyOStream
bool check(const VectorBase< Scalar > &v, Teuchos::FancyOStream *out) const
Check a vector object in a set of comprehensive tests.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void printTestResults(const bool this_result, const Ptr< bool > &success)
Print the test result.
Abstract interface for finite-dimensional dense vectors.
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
Local typedef for scalar magnitude.
VectorTester(const ScalarMag warning_tol=1e-13, const ScalarMag error_tol=1e-10, const int num_random_vectors=1, const bool show_all_tests=false, const bool dump_all=false)
Default constructor which sets default parameter values.
RCP< FancyOStream > getTestOStream()
Return the stream used for testing.