Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64770 - in sandbox/odeint/branches/karsten/libs/numeric/odeint/test: . gmp
From: mario.mulansky_at_[hidden]
Date: 2010-08-12 16:16:40


Author: mariomulansky
Date: 2010-08-12 16:16:38 EDT (Thu, 12 Aug 2010)
New Revision: 64770
URL: http://svn.boost.org/trac/boost/changeset/64770

Log:
added gmp test
switched to dynamic linking of gsl
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile | 20 +++++++++++++++-----
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/Jamfile | 25 ++++++++++++++-----------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/check_gmp.cpp | 35 ++++++++++++++++++++++++++---------
   3 files changed, 55 insertions(+), 25 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile 2010-08-12 16:16:38 EDT (Thu, 12 Aug 2010)
@@ -16,20 +16,30 @@
 
 project
     : requirements
+ <define>BOOST_ALL_NO_LIB=1
       <library>/boost/test//boost_unit_test_framework
- <link>static
+# <link>static
+# <link>shared:<define>BOOST_TEST_DYN_LINK=1
       <include>../../../..
       <include>$BOOST_ROOT
     ;
 
     
-lib libgsl : : <name>gsl ;
-lib libgslcblas : : <name>gslcblas ;
+lib libgsl : : <name>gsl <link>shared ;
+lib libgslcblas : : <name>gslcblas <link>shared ;
 
 test-suite "odeint"
     :
- [ run check_stepper_concepts.cpp libgsl libgslcblas ]
- [ run check_resize.cpp ]
+ [ run check_stepper_concepts.cpp libgsl libgslcblas
+ :
+ :
+ : <link>shared:<define>BOOST_TEST_DYN_LINK=1
+ ]
+ [ run check_resize.cpp
+ :
+ :
+ : <link>static
+ ]
     ;
 
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/Jamfile 2010-08-12 16:16:38 EDT (Thu, 12 Aug 2010)
@@ -6,23 +6,26 @@
 
 import testing ;
 
-#project
-# : requirements
-# <define>blub=1
-# <library>/boost/test//boost_unit_test_framework
+project
+ : requirements
+ <library>/boost/test//boost_unit_test_framework
+# <link>static
 # <link>shared:<define>BOOST_TEST_DYN_LINK=1
-# <link>static
-# <include>../../../..
-# <include>$BOOST_ROOT
-# ;
-
+ <include>../../../../..
+ <include>$BOOST_ROOT
+ ;
+
+
 lib libgmp : : <name>gmp <link>shared ;
 lib libgmpxx : : <name>gmpxx <link>shared ;
-#lib libgmpxx : : <file>/usr/lib64/libgmpxx.so ;
 
 test-suite "gmp"
     :
- [ run check_gmp.cpp libgmpxx libgmp ]
+ [ run check_gmp.cpp libgmpxx libgmp
+ :
+ :
+ : <link>shared:<define>BOOST_TEST_DYN_LINK=1
+ ]
     ;
 
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/check_gmp.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/check_gmp.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gmp/check_gmp.cpp 2010-08-12 16:16:38 EDT (Thu, 12 Aug 2010)
@@ -10,30 +10,47 @@
  copy at http://www.boost.org/LICENSE_1_0.txt)
 */
 
+#define BOOST_TEST_MODULE test_gmp
 
-#include <vector>
+#include <gmpxx.h>
 
 #include <boost/test/unit_test.hpp>
+#include <boost/array.hpp>
 
 #include <boost/numeric/odeint.hpp>
 
 using namespace boost::unit_test;
 using namespace boost::numeric::odeint;
 
+const int precision = 1024;
 
-//#define BOOST_TEST_DYN_LINK
+typedef mpf_class value_type;
+typedef boost::array< value_type , 1 > state_type;
 
-void test_gmp()
+
+void constant_system( state_type &x , state_type &dxdt , value_type t )
 {
- //BOOST_CHECK( 1 == 0 );
+ dxdt[0] = value_type( 1.0 , precision );
 }
 
-test_suite* init_unit_test_suite( int argc , char* argv[] )
+
+BOOST_AUTO_TEST_CASE( test_gmp )
 {
- test_suite *test = BOOST_TEST_SUITE( "check gmp" );
+ /* We have to specify the desired precision in advance! */
+ mpf_set_default_prec( precision );
 
- test->add( BOOST_TEST_CASE(test_gmp) );
+ mpf_t eps_ , unity;
+ mpf_init( eps_ ); mpf_init( unity );
+ mpf_set_d( unity , 1.0 );
+ mpf_div_2exp( eps_ , unity , precision-1 ); // 2^(-precision+1) : smallest number that can be represented with used precision
+ value_type eps( eps_ );
+
+ explicit_rk4< state_type , value_type > stepper;
+ state_type x;
+ x[0] = 0.0;
 
- return test;
-}
+ stepper.do_step( constant_system , x , 0.0 , 0.1 );
 
+ BOOST_MESSAGE( eps );
+ BOOST_CHECK_MESSAGE( abs( x[0] - value_type( 0.1 , precision ) ) < eps , x[0] - 0.1 );
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk