HermiteUnitTests.cpp

Go to the documentation of this file.
00001 // $Id: HermiteUnitTests.cpp,v 1.1 2008/05/16 19:32:59 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/test/TestSuite/HermiteUnitTests.cpp,v $ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #include "HermiteUnitTests.hpp"
00033 
00034 CPPUNIT_TEST_SUITE_REGISTRATION( HermiteUnitTest );
00035 
00036 HermiteUnitTest::HermiteUnitTest() :
00037   urand(0.0, 1.0), tol_a(1.0e-15), tol_r(1.0e-14) {
00038   Teuchos::RCP<basis_type> basis = Teuchos::rcp(new basis_type(0));
00039   Teuchos::RCP<exp_type> expansion = Teuchos::rcp(new exp_type(basis));
00040   pce_type::initExpansion(expansion);
00041 }
00042 
00043 HermiteUnitTest::HermiteUnitTest(double absolute_tolerance, 
00044          double relative_tolerance) :
00045   urand(0.0, 1.0), 
00046   tol_a(absolute_tolerance), 
00047   tol_r(relative_tolerance) {}
00048 
00049 void HermiteUnitTest::setUp() {
00050   double val;
00051 
00052   val = urand.number();
00053   ac = pce_type(val);
00054   a = val;
00055   
00056   val = urand.number();
00057   bc = pce_type(val);
00058   b = val;
00059 
00060 //   cc = pce_type(0.0);
00061 //   c = 0.0;
00062 }
00063 
00064 void HermiteUnitTest::tearDown() {}
00065 
00066 void HermiteUnitTest::comparePCEs(const pce_type& xc, double x) {
00067 
00068   // Compare sizes
00069   CPPUNIT_ASSERT(xc.size() == 1);
00070   
00071   // Compare hasFastAccess
00072   CPPUNIT_ASSERT(xc.hasFastAccess(0) == true);
00073   
00074   // Compare values
00075   compareDoubles(xc.coeff(0), x);
00076 }
00077 
00078 void HermiteUnitTest::compareDoubles(double a, double b) {
00079   CPPUNIT_ASSERT( fabs(a-b) < tol_a + tol_r*fabs(a) );
00080 }

Generated on Wed May 12 21:59:04 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7