test_linear_combination.cpp

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 #include "Teuchos_GlobalMPISession.hpp"
00030 #include "Teuchos_DefaultComm.hpp"
00031 #include "Thyra_VectorImpl.hpp"
00032 #include "Thyra_VectorSpaceImpl.hpp"
00033 #include "Thyra_LinearCombinationTester.hpp"
00034 #include "Thyra_DefaultSpmdVectorSpace.hpp"
00035 #include "Teuchos_CommandLineProcessor.hpp"
00036 #include "Teuchos_ScalarTraits.hpp"
00037 #include "Teuchos_StandardCatchMacros.hpp"
00038 #include "Teuchos_VerboseObject.hpp"
00039 
00040 using namespace Teuchos;
00041 using namespace Thyra;
00042 
00043 
00044 #define SKIP_BLOCK_TESTS
00045 
00046 #define TEST_FLOATS
00047 #define TEST_COMPLEX
00048 
00049 template <class Scalar> inline 
00050 bool runTests(int n, Teuchos::RefCountPtr<Teuchos::FancyOStream>& out)
00051 {
00052   typedef typename Teuchos::ScalarTraits<Scalar> ST;
00053   typedef typename ST::magnitudeType Mag;
00054 
00055   Mag epsErr = n * 1.0e2 * ST::prec();
00056   Mag epsWarn = 1.0e2 * epsErr;
00057 
00058   /* ------- test on a monolithic space ------------ */
00059   
00060   *out << "======= Testing on a monolithic vector space ======" << std::endl;
00061   VectorSpace<Scalar> space 
00062     = new DefaultSpmdVectorSpace<Scalar>(DefaultComm<Index>::getComm(),n,-1);
00063   
00064   TestSpecifier<Scalar> spec(true, epsErr, epsWarn);
00065   
00066   LinearCombinationTester<Scalar> tester(DefaultComm<Index>::getComm(),
00067                                          space, out, spec); 
00068   
00069   return tester.runAllTests();
00070 }  
00071 
00072 int main( int argc, char *argv[] ) 
00073 {
00074   bool success = false;
00075   
00076   GlobalMPISession mpiSession(&argc, &argv);
00077     
00078   // Get stream that can print to just root or all streams!
00079   Teuchos::RefCountPtr<Teuchos::FancyOStream>
00080     out = Teuchos::VerboseObjectBase::getDefaultOStream();
00081   
00082   try {
00083     
00084     int  n = 20;
00085     CommandLineProcessor  clp;
00086     clp.throwExceptions(false);
00087     bool verbose = false;
00088     clp.addOutputSetupOptions(true);
00089     clp.setOption( "verbose", "quiet", &verbose, "Determines if any output is printed or not." );
00090     clp.setOption( "local-dim", &n, "Local number of elements in each constituent vector." );
00091     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00092     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
00093 
00094     if (!verbose) out = rcp(new FancyOStream(rcp(new oblackholestream())));
00095     
00096     success = runTests<double>(n, out) ;
00097 
00098     success = runTests<float>(n, out) && success;
00099 
00100 #if defined(HAVE_COMPLEX) && defined(HAVE_TEUCHOS_COMPLEX)
00101     success = runTests<std::complex<double> >(n, out) && success;
00102 #endif
00103   }
00104   
00105   TEUCHOS_STANDARD_CATCH_STATEMENTS(true,out.get()?*out:std::cerr,success)
00106 
00107     if (success)
00108       {
00109         *out << "all tests PASSED!" << std::endl;
00110         return 0;
00111       }
00112     else
00113       {
00114         *out << "at least one test FAILED!" << std::endl;
00115         return 1;
00116       }
00117 }
00118 

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