27 #include "antioch_config.h"
29 #ifdef ANTIOCH_HAVE_GSL
30 #ifdef ANTIOCH_HAVE_CPPUNIT
46 template<
typename Scalar>
47 class GSLSplinerTest :
public GSLSplinerTestBase<Scalar>
57 template<
typename FunctionType>
58 void run_manually_inited_test( Scalar tol )
60 FunctionType exact_func;
61 exact_func.init(this->_x_min, this->_x_max);
63 this->fill_ref(this->_x_ref,this->_y_ref,this->_n_data, this->_x_min, this->_x_max, exact_func );
65 Antioch::GSLSpliner spline;
66 spline.spline_init(this->_x_ref, this->_y_ref);
68 this->compare_values( tol, spline, exact_func );
72 template<
typename FunctionType>
73 void run_constructor_inited_test( Scalar tol )
75 FunctionType exact_func;
76 exact_func.init(this->_x_min, this->_x_max);
78 this->fill_ref(this->_x_ref,this->_y_ref,this->_n_data, this->_x_min, this->_x_max, exact_func );
80 Antioch::GSLSpliner spline(this->_x_ref, this->_y_ref);
82 this->compare_values( tol, spline, exact_func );
86 void compare_values( Scalar tol, Antioch::GSLSpliner& spline, GSLSplinerTestFunction<Scalar>& exact_func )
88 for(
unsigned int n = 0; n < this->_n_test; n++)
90 Scalar x = this->_x_min + (Scalar)(n) * (this->_x_max - this->_x_min) / (Scalar)(this->_n_test-1);
91 Scalar exact_value = exact_func(x);
92 Scalar interp_value = spline.interpolated_value(x);
93 CPPUNIT_ASSERT_DOUBLES_EQUAL( interp_value,
99 void test_manually_inited_spline_constant_func()
101 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10;
103 this->run_manually_inited_test<ConstantTestFunction<Scalar> >(tol);
106 void test_constructor_inited_spline_constant_func()
108 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10;
110 this->run_constructor_inited_test<ConstantTestFunction<Scalar> >(tol);
113 void test_manually_inited_spline_linear_func()
115 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
117 this->run_manually_inited_test<LinearTestFunction<Scalar> >(tol);
120 void test_constructor_inited_spline_linear_func()
122 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
124 this->run_constructor_inited_test<LinearTestFunction<Scalar> >(tol);
127 void test_manually_inited_spline_cubic_func()
129 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
131 this->run_manually_inited_test<CubicTestFunction<Scalar> >(tol);
134 void test_constructor_inited_spline_cubic_func()
136 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
138 this->run_constructor_inited_test<CubicTestFunction<Scalar> >(tol);
142 class GslSplinerFloatTest :
public GSLSplinerTest<float>
145 CPPUNIT_TEST_SUITE( GslSplinerFloatTest );
147 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
148 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
149 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
150 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
151 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
152 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
154 CPPUNIT_TEST_SUITE_END();
157 class GslSplinerDoubleTest :
public GSLSplinerTest<double>
160 CPPUNIT_TEST_SUITE( GslSplinerDoubleTest );
162 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
163 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
164 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
165 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
166 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
167 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
169 CPPUNIT_TEST_SUITE_END();
177 #endif // ANTIOCH_HAVE_CPPUNIT
178 #endif // ANTIOCH_HAVE_GSL
CPPUNIT_TEST_SUITE_REGISTRATION(ArrheniusRateEigenFloatTest)