00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_VECTOR_SPACE_TESTER_HPP
00030 #define THYRA_VECTOR_SPACE_TESTER_HPP
00031
00032 #include "Thyra_VectorSpaceTesterDecl.hpp"
00033 #include "Thyra_TestingTools.hpp"
00034
00035 namespace Thyra {
00036
00037 template <class Scalar>
00038 VectorSpaceTester<Scalar>::VectorSpaceTester(
00039 const ScalarMag warning_tol
00040 ,const ScalarMag error_tol
00041 ,const int num_random_vectors
00042 ,const int num_mv_cols
00043 ,const bool show_all_tests
00044 ,const bool dump_all
00045 )
00046 :num_mv_cols_(num_mv_cols)
00047 ,warning_tol_(warning_tol)
00048 ,error_tol_(error_tol)
00049 ,num_random_vectors_(num_random_vectors)
00050 ,show_all_tests_(show_all_tests)
00051 ,dump_all_(dump_all)
00052 {
00053 vectorTester_.warning_tol(warning_tol);
00054 vectorTester_.error_tol(error_tol);
00055 vectorTester_.num_random_vectors(num_random_vectors);
00056 vectorTester_.show_all_tests(show_all_tests);
00057 vectorTester_.dump_all(dump_all);
00058 }
00059
00060 template <class Scalar>
00061 bool VectorSpaceTester<Scalar>::check(
00062 const VectorSpaceBase<Scalar> &vs
00063 ,Teuchos::FancyOStream *out_arg
00064 ) const
00065 {
00066 using std::endl;
00067 using Teuchos::describe;
00068 using Teuchos::FancyOStream;
00069 using Teuchos::OSTab;
00070 typedef Teuchos::ScalarTraits<Scalar> ST;
00071 typedef typename ST::magnitudeType ScalarMag;
00072
00073 Teuchos::RCP<FancyOStream> out = Teuchos::rcp(out_arg,false);
00074 const Teuchos::EVerbosityLevel verbLevel = (dump_all()?Teuchos::VERB_EXTREME:Teuchos::VERB_MEDIUM);
00075
00076 OSTab tab(out,1,"THYRA");
00077
00078 bool result, success = true;
00079
00080 if(out.get()) *out <<endl<< "*** Entering Thyra::VectorSpaceTester<"<<ST::name()<<">::check(vs,...) ...\n";
00081
00082 if(out.get()) *out <<endl<< "Testing a vector space vs described as:\n" << describe(vs,verbLevel);
00083
00084 if(out.get())
00085 *out
00086 <<endl<< "A) Calling basic query functions ...\n"
00087 <<endl<< "vs.dim() = " << vs.dim()
00088 <<endl<< "vs.hasInCoreView() = " << vs.hasInCoreView() << std::endl;
00089
00090 if(out.get()) *out <<endl<< "B) Checking that vs is compatible with itself ...\n";
00091
00092 if(out.get()) *out <<endl<< "vs.isCompatible(vs)=";
00093 result = vs.isCompatible(vs);
00094 if(!result) success = false;
00095 if(out.get()) *out << result << " == true : " << passfail(result) << std::endl;
00096
00097 if(out.get()) *out <<endl<< "C) Creating a randomized vector member v ...\n";
00098 Teuchos::RCP<Thyra::VectorBase<Scalar> >
00099 v = createMember(vs);
00100 randomize(Scalar(-ST::one()),Scalar(+ST::one()),&*v);
00101
00102 if(out.get()) *out <<endl<< "D) Testing the VectorBase interface of v ...\n";
00103
00104 result = vectorTester_.check(*v,out.get());
00105 if(!result) success = false;
00106
00107 if(out.get()) *out <<endl<< "C) Creating a randomized MultiVector member mv ...\n";
00108 Teuchos::RCP<Thyra::MultiVectorBase<Scalar> >
00109 mv = createMembers(vs,num_mv_cols());
00110 randomize(Scalar(-ST::one()),Scalar(+ST::one()),&*mv);
00111
00112 if(out.get()) *out <<endl<< "D) Testing the MultiVectorBase interface of mv ...\n";
00113
00114 result = vectorTester_.multiVectorTester().check(*mv,out.get());
00115 if(!result) success = false;
00116
00117 if(out.get()) {
00118 if(success)
00119 *out << endl <<"Congratulations, this VectorSpaceBase object seems to check out!\n";
00120 else
00121 *out << endl <<"Oh no, at least one of the tests performed with this VectorSpaceBase object failed (see above failures)!\n";
00122 *out << endl << "*** Leaving VectorSpaceTester<"<<ST::name()<<">::check(vs,...)\n";
00123 }
00124
00125 return success;
00126
00127 }
00128
00129 }
00130
00131 #endif // THYRA_VECTOR_SPACE_TESTER_HPP