10 #ifndef THYRA_VECTOR_SPACE_TESTER_HPP
11 #define THYRA_VECTOR_SPACE_TESTER_HPP
13 #include "Thyra_VectorSpaceTester_decl.hpp"
14 #include "Thyra_TestingTools.hpp"
15 #include "Thyra_VectorStdOps.hpp"
16 #include "Thyra_MultiVectorStdOps.hpp"
17 #include "Teuchos_TestingHelpers.hpp"
23 template <
class Scalar>
27 ,
const int num_random_vectors_in
28 ,
const int num_mv_cols_in
29 ,
const bool show_all_tests_in
30 ,
const bool dump_all_in
32 :num_mv_cols_(num_mv_cols_in)
33 ,warning_tol_(warning_tol_in)
34 ,error_tol_(error_tol_in)
35 ,num_random_vectors_(num_random_vectors_in)
36 ,show_all_tests_(show_all_tests_in)
37 ,dump_all_(dump_all_in)
41 template <
class Scalar>
48 using Teuchos::describe;
57 OSTab tab(out,1,
"THYRA");
59 bool result, success =
true;
61 if (
nonnull(out)) *out <<endl<<
"*** Entering Thyra::VectorSpaceTester<"<<ST::name()<<
">::check(vs,...) ...\n";
63 if (
nonnull(out)) *out <<endl<<
"Testing a vector space vs described as:\n" << describe(vs,verbLevel);
67 <<endl<<
"A) Calling basic query functions ...\n"
68 <<endl<<
"vs.dim() = " << vs.
dim()
69 <<endl<<
"vs.hasInCoreView() = " << vs.
hasInCoreView() << std::endl;
71 if (
nonnull(out)) *out <<endl<<
"B) Checking that vs is compatible with itself, cloning, etc. ...\n";
80 if (
nonnull(out)) *out <<endl<<
"C) Creating a randomized vector member v ...\n";
83 randomize(Scalar(-ST::one()),Scalar(+ST::one()),v.
ptr());
85 if (
nonnull(out)) *out <<endl<<
"D) Testing the VectorBase interface of v ...\n";
87 result = vectorTester_.check(*v,out.
get());
88 if(!result) success =
false;
90 if (
nonnull(out)) *out <<endl<<
"C) Creating a randomized MultiVector member mv ...\n";
92 mv = createMembers(vs,num_mv_cols());
93 randomize(Scalar(-ST::one()),Scalar(+ST::one()),mv.
ptr());
95 if (
nonnull(out)) *out <<endl<<
"D) Testing the MultiVectorBase interface of mv ...\n";
97 result = vectorTester_.multiVectorTester().check(*mv, out.
ptr());
98 if(!result) success =
false;
102 *out << endl <<
"Congratulations, this VectorSpaceBase object seems to check out!\n";
104 *out << endl <<
"Oh no, at least one of the tests performed with this VectorSpaceBase object failed (see above failures)!\n";
105 *out << endl <<
"*** Leaving VectorSpaceTester<"<<ST::name()<<
">::check(vs,...)\n";
116 #endif // THYRA_VECTOR_SPACE_TESTER_HPP
basic_OSTab< char > OSTab
virtual RCP< const VectorSpaceBase< Scalar > > clone() const
Clone this object (if supported).
basic_FancyOStream< char > FancyOStream
Abstract interface for objects that represent a space for vectors.
VectorSpaceTester(const ScalarMag warning_tol=1e-13, const ScalarMag error_tol=1e-10, const int num_random_vectors=1, const int num_mv_cols=4, const bool show_all_tests=false, const bool dump_all=false)
Default constructor which sets default parameter values.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define TEUCHOS_TEST_ASSERT(v1, out, success)
bool nonnull(const boost::shared_ptr< T > &p)
Teuchos::ScalarTraits< Scalar >::magnitudeType ScalarMag
Local typedef for scalar magnitude.
bool check(const VectorSpaceBase< Scalar > &vs, Teuchos::FancyOStream *out) const
Check a vector space and the objects it creates through a set of comprehensive tests.
virtual bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const =0
Compare the compatibility of two vector spaces.
virtual Ordinal dim() const =0
Return the dimension of the vector space.
virtual bool hasInCoreView(const Range1D &rng=Range1D(), const EViewType viewType=VIEW_TYPE_DETACHED, const EStrideType strideType=STRIDE_TYPE_NONUNIT) const
Returns true if this->acquireDetachedView(rng,...) returns a direct view of the range of data request...