|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Thyra: Interfaces and Support for Abstract Numerical Algorithms 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef THYRA_TESTING_TOOLS_DECL_HPP 00030 #define THYRA_TESTING_TOOLS_DECL_HPP 00031 00032 #include "Thyra_OperatorVectorTypes.hpp" 00033 #include "Teuchos_VerbosityLevel.hpp" 00034 #include "Teuchos_TestingHelpers.hpp" 00035 00036 namespace Thyra { 00037 00038 00043 inline const std::string passfail(const bool result) 00044 { 00045 return Teuchos::passfail(result); 00046 } 00047 00048 00053 template <class Scalar> 00054 inline 00055 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00056 relErr( const Scalar &s1, const Scalar &s2 ) 00057 { 00058 return Teuchos::relErr<Scalar>(s1, s2); 00059 } 00060 00067 template <class Scalar> 00068 typename Teuchos::ScalarTraits<Scalar>::magnitudeType 00069 relVectorErr( const VectorBase<Scalar> &v1, const VectorBase<Scalar> &v2 ); 00070 00077 template<class Scalar> 00078 inline 00079 bool testRelErr( 00080 const std::string &v1_name 00081 ,const Scalar &v1 00082 ,const std::string &v2_name 00083 ,const Scalar &v2 00084 ,const std::string &maxRelErr_error_name 00085 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error 00086 ,const std::string &maxRelErr_warning_name 00087 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning 00088 ,std::ostream *out 00089 ,const std::string &leadingIndent = std::string("") 00090 ) 00091 { 00092 // ToDo: Indent correctly! 00093 return Teuchos::testRelErr(v1_name, v1, v2_name, v2, 00094 maxRelErr_error_name, maxRelErr_error, 00095 maxRelErr_warning_name, maxRelErr_warning, 00096 Teuchos::ptr(out) ); 00097 } 00098 00109 template<class Scalar1, class Scalar2, class ScalarMag> 00110 bool testRelErrors( 00111 const int num_scalars 00112 ,const std::string &v1_name 00113 ,const Scalar1 v1[] 00114 ,const std::string &v2_name 00115 ,const Scalar2 v2[] 00116 ,const std::string &maxRelErr_error_name 00117 ,const ScalarMag &maxRelErr_error 00118 ,const std::string &maxRelErr_warning_name 00119 ,const ScalarMag &maxRelErr_warning 00120 ,std::ostream *out 00121 ,const std::string &leadingIndent = std::string("") 00122 ); 00123 00134 template<class Scalar> 00135 bool testRelNormDiffErr( 00136 const std::string &v1_name, 00137 const VectorBase<Scalar> &v1, 00138 const std::string &v2_name, 00139 const VectorBase<Scalar> &v2, 00140 const std::string &maxRelErr_error_name, 00141 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error, 00142 const std::string &maxRelErr_warning_name, 00143 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning, 00144 std::ostream *out, 00145 const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_LOW, 00146 const std::string &leadingIndent = std::string("") 00147 ); 00148 00155 template<class Scalar> 00156 bool testMaxErr( 00157 const std::string &error_name 00158 ,const Scalar &error 00159 ,const std::string &max_error_name 00160 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error 00161 ,const std::string &max_warning_name 00162 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning 00163 ,std::ostream *out 00164 ,const std::string &leadingIndent = std::string("") 00165 ); 00166 00175 template<class Scalar> 00176 bool testMaxErrors( 00177 const int num_scalars 00178 ,const std::string &error_name 00179 ,const Scalar error[] 00180 ,const std::string &max_error_name 00181 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error 00182 ,const std::string &max_warning_name 00183 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning 00184 ,std::ostream *out 00185 ,const std::string &leadingIndent = std::string("") 00186 ); 00187 00194 bool testBoolExpr( 00195 const std::string &boolExprName 00196 ,const bool &boolExpr 00197 ,const bool &boolExpected 00198 ,std::ostream *out 00199 ,const std::string &leadingIndent = std::string("") 00200 ); 00201 00222 void printTestResults( 00223 const bool result 00224 ,const std::string &test_summary 00225 ,const bool show_all_tests 00226 ,bool *success 00227 ,std::ostream *out 00228 ); 00229 00236 template<class Scalar> 00237 std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v ); 00238 00245 template<class Scalar> 00246 std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M ); 00247 00248 } // namespace Thyra 00249 00250 // ////////////////////////// 00251 // Inline functions 00252 00253 inline 00254 void Thyra::printTestResults( 00255 const bool result 00256 ,const std::string &test_summary 00257 ,const bool show_all_tests 00258 ,bool *success 00259 ,std::ostream *out 00260 ) 00261 { 00262 if(!result) *success = false; 00263 if(out) { 00264 if( !result || show_all_tests ) 00265 *out << std::endl << test_summary; 00266 else 00267 *out << "passed!\n"; 00268 } 00269 } 00270 00271 #endif // THYRA_TESTING_TOOLS_DECL_HPP
1.7.4