42 #ifndef THYRA_VECTOR_TESTER_HPP
43 #define THYRA_VECTOR_TESTER_HPP
45 #include "Thyra_VectorTester_decl.hpp"
46 #include "Thyra_VectorStdOps.hpp"
47 #include "Thyra_VectorBase.hpp"
48 #include "Thyra_VectorSpaceBase.hpp"
49 #include "Thyra_TestingTools.hpp"
50 #include "Teuchos_VerbosityLevel.hpp"
56 template<
class Scalar>
60 ,
const int num_random_vectors_in
61 ,
const bool show_all_tests_in
62 ,
const bool dump_all_in
64 :warning_tol_(warning_tol_in)
65 ,error_tol_(error_tol_in)
66 ,num_random_vectors_(num_random_vectors_in)
67 ,show_all_tests_(show_all_tests_in)
68 ,dump_all_(dump_all_in)
72 template<
class Scalar>
80 using Teuchos::describe;
89 OSTab tab(out,1,
"THYRA");
91 bool result, success =
true;
93 if(out.
get()) *out <<endl<<
"*** Entering Thyra::VectorTester<"<<ST::name()<<
">::check(v,...) ...\n";
95 if(out.
get()) *out <<endl<<
"Testing a VectorBase object described as:\n" << describe(v,verbLevel);
97 if(out.
get()) *out <<endl<<
"A) Creating temporary vector t1, t2, t3, and t4 from v.space() ...\n";
101 t1 = createMember(vs), t2 = createMember(vs), t3 = createMember(vs), t4 = createMember(vs);
103 if(out.
get()) *out <<endl<<
"B) Testing VectorBase::applyOp(...) by calling a few standard RTOp operations ... ";
108 three = Scalar(3)*one;
111 using Teuchos::inoutArg;
116 bool these_results =
true;
118 *testOut <<endl<<
"assign(t1.ptr(),2.0) ...\n";
119 Thyra::assign( t1.
ptr(), two );
120 if(dump_all()) *testOut <<endl<<
"\nt1 =\n" << describe(*t1,verbLevel);
122 result = Teuchos::testRelErr<Scalar>(
123 "sum(t1)", sum(*t1),
"2*vs->dim()", two*Scalar(vs->dim()),
124 "error_tol()", error_tol(),
"warning_tol()", warning_tol(),
127 if(!result) these_results =
false;
129 *testOut <<endl<<
"assign(t2.ptr(),3.0) ...\n";
130 Thyra::assign( t2.ptr(), three );
131 if(dump_all()) *testOut <<endl<<
"t2 =\n" << *t1;
133 result = Teuchos::testRelErr<Scalar>(
134 "sum(t2)",sum(*t2),
"3*vs->dim()",three*Scalar(vs->dim()),
135 "error_tol()",error_tol(),
"warning_tol()",warning_tol(),
138 if(!result) these_results =
false;
140 result = Teuchos::testRelErr<Scalar>(
141 "vs->scalarProd(*t1,*t2)",vs->scalarProd(*t1,*t2),
"2*3*vs->dim()",two*three*Scalar(vs->dim()),
142 "error_tol()",error_tol(),
"warning_tol()",warning_tol(),
145 if(!result) these_results =
false;
153 if(out.
get()) *out <<endl<<
"C) Checking the MultiVectorBase interface of v ...\n";
154 result = multiVectorTester_.check(v, out.
ptr());
155 if(!result) success =
false;
157 if(out.
get()) *out <<endl<<
"*** Leaving Thyra::VectorTester<"<<ST::name()<<
">::check(v,...) ...\n";
167 #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.