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"
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)
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";
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";
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()),
95 if(!result) these_results =
false;
97 *testOut <<endl<<
"assign(t2.ptr(),3.0) ...\n";
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()),
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()),
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";
void assign(const Ptr< MultiVectorBase< Scalar > > &V, Scalar alpha)
V = alpha.
Control printing of test results.
RCP< FancyOStream > getTestOStream()
Return the stream used for testing.
void printTestResults(const bool this_result, const Ptr< bool > &success)
Print the test result.
Abstract interface for finite-dimensional dense vectors.
Scalar sum(const VectorBase< Scalar > &v)
Sum of vector elements: result = sum( v(i), i = 0...v.space()->dim()-1 ).
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
RCP< VectorBase< Scalar > > createMember(const RCP< const VectorSpaceBase< Scalar > > &vs, const std::string &label="")
Create a vector member from the vector space.
void warning_tol(const ScalarMag &warning_tol)
Set the tolerance above which a relative error will generate a warning message.
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.
void error_tol(const ScalarMag &error_tol)
Set the error above which a relative error will generate a an message and cause the test to fail.
void dump_all(const bool dump_all)
Set whether all of the vectors and multi-vectors will be dumped or not.
void show_all_tests(const bool show_all_tests)
Set whether all of the tests will be printed independent if they pass or fail.
bool check(const VectorBase< Scalar > &v, Teuchos::FancyOStream *out) const
Check a vector object in a set of comprehensive tests.
basic_FancyOStream< char > FancyOStream
basic_OSTab< char > OSTab
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)