Thyra_TestingToolsDecl.hpp

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 
00052 inline const std::string passfail(const bool result)
00053 {
00054   return Teuchos::passfail(result);
00055 }
00056 
00057 
00062 template <class Scalar>
00063 inline
00064 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00065 relErr( const Scalar &s1, const Scalar &s2 )
00066 {
00067   return Teuchos::relErr<Scalar>(s1, s2);
00068 }
00069 
00076 template <class Scalar>
00077 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00078 relVectorErr( const VectorBase<Scalar> &v1, const VectorBase<Scalar> &v2 );
00079 
00086 template<class Scalar>
00087 inline
00088 bool testRelErr(
00089   const std::string &v1_name
00090   ,const Scalar &v1
00091   ,const std::string &v2_name
00092   ,const Scalar &v2
00093   ,const std::string &maxRelErr_error_name
00094   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error
00095   ,const std::string &maxRelErr_warning_name
00096   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning
00097   ,std::ostream *out
00098   ,const std::string &leadingIndent = std::string("")
00099   )
00100 {
00101   // ToDo: Indent correctly!
00102   return Teuchos::testRelErr(v1_name, v1, v2_name, v2,
00103     maxRelErr_error_name, maxRelErr_error,
00104     maxRelErr_warning_name, maxRelErr_warning,
00105     Teuchos::ptr(out) );
00106 }
00107 
00118 template<class Scalar1, class Scalar2, class ScalarMag>
00119 bool testRelErrors(
00120   const int                                                     num_scalars
00121   ,const std::string                                            &v1_name
00122   ,const Scalar1                                                v1[]
00123   ,const std::string                                            &v2_name
00124   ,const Scalar2                                                v2[]
00125   ,const std::string                                            &maxRelErr_error_name
00126   ,const ScalarMag                                              &maxRelErr_error
00127   ,const std::string                                            &maxRelErr_warning_name
00128   ,const ScalarMag                                              &maxRelErr_warning
00129   ,std::ostream                                                 *out
00130   ,const std::string                                            &leadingIndent = std::string("")
00131   );
00132 
00143 template<class Scalar>
00144 bool testRelNormDiffErr(
00145   const std::string &v1_name,
00146   const VectorBase<Scalar> &v1,
00147   const std::string &v2_name,
00148   const VectorBase<Scalar> &v2,
00149   const std::string &maxRelErr_error_name,
00150   const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error,
00151   const std::string &maxRelErr_warning_name,
00152   const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning,
00153   std::ostream *out,
00154   const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_LOW,
00155   const std::string &leadingIndent = std::string("")
00156   );
00157 
00164 template<class Scalar>
00165 bool testMaxErr(
00166   const std::string                                             &error_name
00167   ,const Scalar                                                 &error
00168   ,const std::string                                            &max_error_name
00169   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_error
00170   ,const std::string                                            &max_warning_name
00171   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_warning
00172   ,std::ostream                                                 *out
00173   ,const std::string                                            &leadingIndent = std::string("")
00174   );
00175 
00184 template<class Scalar>
00185 bool testMaxErrors(
00186   const int                                                     num_scalars
00187   ,const std::string                                            &error_name
00188   ,const Scalar                                                 error[]
00189   ,const std::string                                            &max_error_name
00190   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_error
00191   ,const std::string                                            &max_warning_name
00192   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_warning
00193   ,std::ostream                                                 *out
00194   ,const std::string                                            &leadingIndent = std::string("")
00195   );
00196 
00203 bool testBoolExpr(
00204   const std::string    &boolExprName
00205   ,const bool          &boolExpr
00206   ,const bool          &boolExpected
00207   ,std::ostream        *out
00208   ,const std::string   &leadingIndent = std::string("")
00209   );
00210 
00231 void printTestResults(
00232   const bool              result
00233   ,const std::string      &test_summary
00234   ,const bool             show_all_tests
00235   ,bool                   *success
00236   ,std::ostream           *out
00237   );
00238 
00245 template<class Scalar>
00246 std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v );
00247 
00254 template<class Scalar>
00255 std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M );
00256 
00257 } // namespace Thyra
00258 
00259 // //////////////////////////
00260 // Inline functions                        
00261 
00262 inline
00263 void Thyra::printTestResults(
00264   const bool              result
00265   ,const std::string      &test_summary
00266   ,const bool             show_all_tests
00267   ,bool                   *success
00268   ,std::ostream           *out
00269   )
00270 {
00271   if(!result) *success = false;
00272   if(out) {
00273     if( !result || show_all_tests )
00274       *out << std::endl << test_summary;
00275     else
00276       *out << "passed!\n";
00277   }
00278 }
00279 
00280 #endif // THYRA_TESTING_TOOLS_DECL_HPP

Generated on Wed May 12 21:42:28 2010 for Thyra Operator/Vector Support by  doxygen 1.4.7