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 
00034 namespace Thyra {
00035 
00049 inline
00050 const char* passfail(bool pass) { return pass ? "passed" : "failed"; }
00051 
00058 template <class Scalar>
00059 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00060 relErr( const Scalar &s1, const Scalar &s2 );
00061 
00068 template<class Scalar>
00069 bool testRelErr(
00070   const std::string                                             &v1_name
00071   ,const Scalar                                                 &v1
00072   ,const std::string                                            &v2_name
00073   ,const Scalar                                                 &v2
00074   ,const std::string                                            &maxRelErr_error_name
00075   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &maxRelErr_error
00076   ,const std::string                                            &maxRelErr_warning_name
00077   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &maxRelErr_warning
00078   ,std::ostream                                                 *out
00079   ,const std::string                                            &leadingIndent = std::string("")
00080   );
00081 
00092 template<class Scalar1, class Scalar2, class ScalarMag>
00093 bool testRelErrors(
00094   const int                                                     num_scalars
00095   ,const std::string                                            &v1_name
00096   ,const Scalar1                                                v1[]
00097   ,const std::string                                            &v2_name
00098   ,const Scalar2                                                v2[]
00099   ,const std::string                                            &maxRelErr_error_name
00100   ,const ScalarMag                                              &maxRelErr_error
00101   ,const std::string                                            &maxRelErr_warning_name
00102   ,const ScalarMag                                              &maxRelErr_warning
00103   ,std::ostream                                                 *out
00104   ,const std::string                                            &leadingIndent = std::string("")
00105   );
00106 
00113 template<class Scalar>
00114 bool testMaxErr(
00115   const std::string                                             &error_name
00116   ,const Scalar                                                 &error
00117   ,const std::string                                            &max_error_name
00118   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_error
00119   ,const std::string                                            &max_warning_name
00120   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_warning
00121   ,std::ostream                                                 *out
00122   ,const std::string                                            &leadingIndent = std::string("")
00123   );
00124 
00133 template<class Scalar>
00134 bool testMaxErrors(
00135   const int                                                     num_scalars
00136   ,const std::string                                            &error_name
00137   ,const Scalar                                                 error[]
00138   ,const std::string                                            &max_error_name
00139   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_error
00140   ,const std::string                                            &max_warning_name
00141   ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType  &max_warning
00142   ,std::ostream                                                 *out
00143   ,const std::string                                            &leadingIndent = std::string("")
00144   );
00145 
00152 bool testBoolExpr(
00153   const std::string    &boolExprName
00154   ,const bool          &boolExpr
00155   ,const bool          &boolExpected
00156   ,std::ostream        *out
00157   ,const std::string   &leadingIndent = std::string("")
00158   );
00159 
00180 void printTestResults(
00181   const bool              result
00182   ,const std::string      &test_summary
00183   ,const bool             show_all_tests
00184   ,bool                   *success
00185   ,std::ostream           *out
00186   );
00187 
00194 template<class Scalar>
00195 std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v );
00196 
00203 template<class Scalar>
00204 std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M );
00205 
00206 } // namespace Thyra
00207 
00208 // //////////////////////////
00209 // Inline functions                        
00210 
00211 inline
00212 void Thyra::printTestResults(
00213   const bool              result
00214   ,const std::string      &test_summary
00215   ,const bool             show_all_tests
00216   ,bool                   *success
00217   ,std::ostream           *out
00218   )
00219 {
00220   if(!result) *success = false;
00221   if(out) {
00222     if( !result || show_all_tests )
00223       *out << std::endl << test_summary;
00224     else
00225       *out << "passed!\n";
00226   }
00227 }
00228 
00229 #endif // THYRA_TESTING_TOOLS_DECL_HPP

Generated on Thu Sep 18 12:33:03 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1