27 #include "antioch_config.h"
29 #ifdef ANTIOCH_HAVE_GSL
30 #ifdef ANTIOCH_HAVE_CPPUNIT
36 #ifdef ANTIOCH_HAVE_EIGEN
37 #include "Eigen/Dense"
40 #ifdef ANTIOCH_HAVE_METAPHYSICL
41 #include "metaphysicl/numberarray.h"
44 #ifdef ANTIOCH_HAVE_VEXCL
45 #include "vexcl/vexcl.hpp"
66 template<
typename PairScalars>
67 class GSLSplinerVecTest :
public GSLSplinerTestBase<typename Antioch::value_type<PairScalars>::type>
79 template<
typename VecFunctionType,
typename ScalarFunctionType>
80 void run_manually_inited_test( Scalar tol )
82 ScalarFunctionType exact_func;
83 exact_func.init(this->_x_min, this->_x_max);
85 this->fill_ref(this->_x_ref,this->_y_ref,this->_n_data, this->_x_min, this->_x_max, exact_func );
87 Antioch::GSLSpliner spline;
88 spline.spline_init(this->_x_ref, this->_y_ref);
90 VecFunctionType vec_exact_func;
91 vec_exact_func.init(this->_x_min, this->_x_max);
93 this->compare_values( tol, spline, vec_exact_func );
97 template<
typename VecFunctionType,
typename ScalarFunctionType>
98 void run_constructor_inited_test( Scalar tol )
100 ScalarFunctionType exact_func;
101 exact_func.init(this->_x_min, this->_x_max);
103 this->fill_ref(this->_x_ref,this->_y_ref,this->_n_data, this->_x_min, this->_x_max, exact_func );
105 Antioch::GSLSpliner spline(this->_x_ref, this->_y_ref);
107 VecFunctionType vec_exact_func;
108 vec_exact_func.init(this->_x_min, this->_x_max);
110 this->compare_values( tol, spline, vec_exact_func );
114 void compare_values( Scalar tol,
115 Antioch::GSLSpliner& spline,
116 GSLSplinerTestFunction<PairScalars>& exact_func)
119 PairScalars x = *(this->_example);
121 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
127 const PairScalars gsl_value = spline.interpolated_value(x);
129 const PairScalars exact_value = exact_func(x);
131 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
133 CPPUNIT_ASSERT_DOUBLES_EQUAL( gsl_value[2*tuple],
134 exact_value[2*tuple],
139 void test_manually_inited_spline_constant_func()
141 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10;
143 this->run_manually_inited_test<ConstantTestFunction<PairScalars>,ConstantTestFunction<Scalar> >(tol);
146 void test_constructor_inited_spline_constant_func()
148 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10;
150 this->run_constructor_inited_test<ConstantTestFunction<PairScalars>,ConstantTestFunction<Scalar> >(tol);
153 void test_manually_inited_spline_linear_func()
155 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
157 this->run_manually_inited_test<LinearTestFunction<PairScalars>,LinearTestFunction<Scalar> >(tol);
160 void test_constructor_inited_spline_linear_func()
162 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
164 this->run_constructor_inited_test<LinearTestFunction<PairScalars>,LinearTestFunction<Scalar> >(tol);
167 void test_manually_inited_spline_cubic_func()
169 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
171 this->run_manually_inited_test<CubicTestFunction<PairScalars>,CubicTestFunction<Scalar> >(tol);
174 void test_constructor_inited_spline_cubic_func()
176 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 50;
178 this->run_constructor_inited_test<CubicTestFunction<PairScalars>,CubicTestFunction<Scalar> >(tol);
183 PairScalars* _example;
189 template <
typename Scalar>
190 class GslSplinerValarrayTest :
public GSLSplinerVecTest<std::valarray<Scalar> >
196 this->init_vec_data();
197 this->_example =
new std::valarray<Scalar>(2*ANTIOCH_N_TUPLES);
200 virtual void tearDown()
202 delete this->_example;
207 class GslSplinerValarrayFloatTest :
public GslSplinerValarrayTest<float>
209 CPPUNIT_TEST_SUITE( GslSplinerValarrayFloatTest );
211 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
212 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
213 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
214 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
215 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
216 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
218 CPPUNIT_TEST_SUITE_END();
221 class GslSplinerValarrayDoubleTest :
public GslSplinerValarrayTest<double>
223 CPPUNIT_TEST_SUITE( GslSplinerValarrayDoubleTest );
225 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
226 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
227 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
228 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
229 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
230 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
232 CPPUNIT_TEST_SUITE_END();
235 class GslSplinerValarrayLongDoubleTest :
public GslSplinerValarrayTest<long double>
237 CPPUNIT_TEST_SUITE( GslSplinerValarrayLongDoubleTest );
239 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
240 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
241 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
242 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
243 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
244 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
246 CPPUNIT_TEST_SUITE_END();
256 #ifdef ANTIOCH_HAVE_EIGEN
258 template <
typename Scalar>
259 class GslSplinerEigenTest :
public GSLSplinerVecTest<Eigen::Array<Scalar,2*ANTIOCH_N_TUPLES,1> >
264 this->init_vec_data();
265 this->_example =
new Eigen::Array<Scalar, 2*ANTIOCH_N_TUPLES, 1>();
268 virtual void tearDown()
270 delete this->_example;
274 class GslSplinerEigenFloatTest :
public GslSplinerEigenTest<float>
276 CPPUNIT_TEST_SUITE( GslSplinerEigenFloatTest );
278 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
279 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
280 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
281 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
282 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
283 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
285 CPPUNIT_TEST_SUITE_END();
288 class GslSplinerEigenDoubleTest :
public GslSplinerEigenTest<double>
290 CPPUNIT_TEST_SUITE( GslSplinerEigenDoubleTest );
292 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
293 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
294 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
295 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
296 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
297 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
299 CPPUNIT_TEST_SUITE_END();
302 class GslSplinerEigenLongDoubleTest :
public GslSplinerEigenTest<long double>
304 CPPUNIT_TEST_SUITE( GslSplinerEigenLongDoubleTest );
306 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
307 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
308 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
309 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
310 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
311 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
313 CPPUNIT_TEST_SUITE_END();
320 #endif // ANTIOCH_HAVE_EIGEN
326 #ifdef ANTIOCH_HAVE_METAPHYSICL
328 template <
typename Scalar>
329 class GslSplinerMetaPhysicLTest :
public GSLSplinerVecTest<MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES,Scalar> >
334 this->init_vec_data();
335 this->_example =
new MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES,Scalar>(0);
338 virtual void tearDown()
340 delete this->_example;
344 class GslSplinerMetaPhysicLFloatTest :
public GslSplinerMetaPhysicLTest<float>
346 CPPUNIT_TEST_SUITE( GslSplinerMetaPhysicLFloatTest );
348 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
349 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
350 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
351 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
352 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
353 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
355 CPPUNIT_TEST_SUITE_END();
358 class GslSplinerMetaPhysicLDoubleTest :
public GslSplinerMetaPhysicLTest<double>
360 CPPUNIT_TEST_SUITE( GslSplinerMetaPhysicLDoubleTest );
362 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
363 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
364 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
365 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
366 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
367 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
369 CPPUNIT_TEST_SUITE_END();
372 class GslSplinerMetaPhysicLLongDoubleTest :
public GslSplinerMetaPhysicLTest<long double>
374 CPPUNIT_TEST_SUITE( GslSplinerMetaPhysicLLongDoubleTest );
376 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
377 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
378 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
379 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
380 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
381 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
383 CPPUNIT_TEST_SUITE_END();
390 #endif // ANTIOCH_HAVE_METAPHYSICL
396 #ifdef ANTIOCH_HAVE_VEXCL
398 class GslSplinerVexCLFloatTest :
public GSLSplinerVecTest<vex::vector<float> >
400 CPPUNIT_TEST_SUITE( GslSplinerVexCLFloatTest );
402 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
403 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
404 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
405 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
406 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
407 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
409 CPPUNIT_TEST_SUITE_END();
419 this->init_vec_data();
420 _ctx =
new vex::Context(vex::Filter::All);
421 this->_example =
new vex::vector<float>(*_ctx, 2*ANTIOCH_N_TUPLES);
424 virtual void tearDown()
427 delete this->_example;
431 class GslSplinerVexCLDoubleTest :
public GSLSplinerVecTest<vex::vector<double> >
433 CPPUNIT_TEST_SUITE( GslSplinerVexCLDoubleTest );
435 CPPUNIT_TEST( test_manually_inited_spline_constant_func );
436 CPPUNIT_TEST( test_constructor_inited_spline_constant_func );
437 CPPUNIT_TEST( test_manually_inited_spline_linear_func );
438 CPPUNIT_TEST( test_constructor_inited_spline_linear_func );
439 CPPUNIT_TEST( test_manually_inited_spline_cubic_func );
440 CPPUNIT_TEST( test_constructor_inited_spline_cubic_func );
442 CPPUNIT_TEST_SUITE_END();
452 this->init_vec_data();
453 _ctx =
new vex::Context(vex::Filter::DoublePrecision);
454 this->_example =
new vex::vector<double>(*_ctx, 2*ANTIOCH_N_TUPLES);
457 virtual void tearDown()
460 delete this->_example;
467 #endif // ANTIOCH_HAVE_VEXCL
471 #endif // ANTIOCH_HAVE_CPPUNIT
472 #endif // ANTIOCH_HAVE_GSL
CPPUNIT_TEST_SUITE_REGISTRATION(ArrheniusRateEigenFloatTest)