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