Thyra_TestingToolsDecl.hpp

Go to the documentation of this file.
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 
00035 namespace Thyra {
00036 
00050 inline
00051 const std::string passfail(bool pass) { return ( pass ? "passed" : "failed" ); }
00052 
00059 template <class Scalar>
00060 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00061 relErr( const Scalar &s1, const Scalar &s2 );
00062 
00069 template <class Scalar>
00070 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00071 relVectorErr( const VectorBase<Scalar> &v1, const VectorBase<Scalar> &v2 );
00072 
00079 template<class Scalar>
00080 bool testRelErr(
00081   const std::string                                             &v1_name
00082   ,const Scalar                                                 &v1
00083   ,const std::string                                            &v2_name
00084   ,const Scalar                                                 &v2
00085   ,const std::string                                            &maxRelErr_error_name
00086   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &maxRelErr_error
00087   ,const std::string                                            &maxRelErr_warning_name
00088   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &maxRelErr_warning
00089   ,std::ostream                                                 *out
00090   ,const std::string                                            &leadingIndent = std::string("")
00091   );
00092 
00103 template<class Scalar1, class Scalar2, class ScalarMag>
00104 bool testRelErrors(
00105   const int                                                     num_scalars
00106   ,const std::string                                            &v1_name
00107   ,const Scalar1                                                v1[]
00108   ,const std::string                                            &v2_name
00109   ,const Scalar2                                                v2[]
00110   ,const std::string                                            &maxRelErr_error_name
00111   ,const ScalarMag                                              &maxRelErr_error
00112   ,const std::string                                            &maxRelErr_warning_name
00113   ,const ScalarMag                                              &maxRelErr_warning
00114   ,std::ostream                                                 *out
00115   ,const std::string                                            &leadingIndent = std::string("")
00116   );
00117 
00128 template<class Scalar>
00129 bool testRelNormDiffErr(
00130   const std::string &v1_name,
00131   const VectorBase<Scalar> &v1,
00132   const std::string &v2_name,
00133   const VectorBase<Scalar> &v2,
00134   const std::string &maxRelErr_error_name,
00135   const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error,
00136   const std::string &maxRelErr_warning_name,
00137   const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning,
00138   std::ostream *out,
00139   const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_LOW,
00140   const std::string &leadingIndent = std::string("")
00141   );
00142 
00149 template<class Scalar>
00150 bool testMaxErr(
00151   const std::string                                             &error_name
00152   ,const Scalar                                                 &error
00153   ,const std::string                                            &max_error_name
00154   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_error
00155   ,const std::string                                            &max_warning_name
00156   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_warning
00157   ,std::ostream                                                 *out
00158   ,const std::string                                            &leadingIndent = std::string("")
00159   );
00160 
00169 template<class Scalar>
00170 bool testMaxErrors(
00171   const int                                                     num_scalars
00172   ,const std::string                                            &error_name
00173   ,const Scalar                                                 error[]
00174   ,const std::string                                            &max_error_name
00175   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_error
00176   ,const std::string                                            &max_warning_name
00177   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_warning
00178   ,std::ostream                                                 *out
00179   ,const std::string                                            &leadingIndent = std::string("")
00180   );
00181 
00188 bool testBoolExpr(
00189   const std::string    &boolExprName
00190   ,const bool          &boolExpr
00191   ,const bool          &boolExpected
00192   ,std::ostream        *out
00193   ,const std::string   &leadingIndent = std::string("")
00194   );
00195 
00216 void printTestResults(
00217   const bool              result
00218   ,const std::string      &test_summary
00219   ,const bool             show_all_tests
00220   ,bool                   *success
00221   ,std::ostream           *out
00222   );
00223 
00230 template<class Scalar>
00231 std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v );
00232 
00239 template<class Scalar>
00240 std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M );
00241 
00242 } // namespace Thyra
00243 
00244 // //////////////////////////
00245 // Inline functions                        
00246 
00247 inline
00248 void Thyra::printTestResults(
00249   const bool              result
00250   ,const std::string      &test_summary
00251   ,const bool             show_all_tests
00252   ,bool                   *success
00253   ,std::ostream           *out
00254   )
00255 {
00256   if(!result) *success = false;
00257   if(out) {
00258     if( !result || show_all_tests )
00259       *out << std::endl << test_summary;
00260     else
00261       *out << "passed!\n";
00262   }
00263 }
00264 
00265 #endif // THYRA_TESTING_TOOLS_DECL_HPP

Generated on Tue Oct 20 12:47:27 2009 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.4.7