27 #ifndef ANTIOCH_GSL_SPLINER_TEST_BASE_H
28 #define ANTIOCH_GSL_SPLINER_TEST_BASE_H
30 #include "antioch_config.h"
32 #ifdef ANTIOCH_HAVE_GSL
33 #ifdef ANTIOCH_HAVE_CPPUNIT
35 #include <cppunit/extensions/HelperMacros.h>
36 #include <cppunit/TestCase.h>
40 template<
typename PairScalars>
41 struct GSLSplinerTestFunction
45 virtual PairScalars operator()(
const PairScalars x ) =0;
47 void init( Scalar x_min, Scalar x_max )
54 Scalar _x_min, _x_max;
57 template<
typename Scalar>
58 struct ConstantTestFunction :
public GSLSplinerTestFunction<Scalar>
60 virtual Scalar operator()(
const Scalar x )
67 template<
typename Scalar>
68 struct LinearTestFunction :
public GSLSplinerTestFunction<Scalar>
70 virtual Scalar operator()(
const Scalar x )
76 return ten + five * x;
80 template<
typename Scalar>
81 struct CubicTestFunction :
public GSLSplinerTestFunction<Scalar>
83 virtual Scalar operator()(
const Scalar x )
92 Scalar t = (x-xmin)/(xmax-xmin);
99 Scalar h00 = two*t3 - three*t2 + one;
100 Scalar h10 = t3 - two*t2 + t;
101 Scalar h01 = -two*t3 + three*t2;
102 Scalar h11 = t3 - t2;
104 return h00*xmin + h10*(xmax-xmin) + h01*xmax + h11*(xmax-xmin);
108 template<
typename Scalar>
109 class GSLSplinerTestBase :
public CppUnit::TestCase
117 _x_ref.resize(_n_data);
118 _y_ref.resize(_n_data);
123 void fill_ref(std::vector<Scalar>& x_ref, std::vector<Scalar>& y_ref,
124 unsigned int n_data,
const Scalar& x_min,
const Scalar& x_max,
125 GSLSplinerTestFunction<Scalar>& exact_func)
127 for(
unsigned int i = 0; i < n_data; i++)
129 x_ref[i] = x_min + (Scalar)(i) * (x_max - x_min) / (Scalar)(n_data-1);
130 y_ref[i] = exact_func(x_ref[i]);
136 unsigned int _n_data;
137 unsigned int _n_test;
140 std::vector<Scalar> _x_ref;
141 std::vector<Scalar> _y_ref;
146 #endif // ANTIOCH_HAVE_CPPUNIT
147 #endif // ANTIOCH_HAVE_GSL
149 #endif // ANTIOCH_GSL_SPLINER_TEST_BASE_H
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > constant_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex, const Scalar &value)