31 #include "antioch_config.h"
35 #ifdef ANTIOCH_HAVE_EIGEN
36 #include "Eigen/Dense"
39 #ifdef ANTIOCH_HAVE_METAPHYSICL
40 #include "metaphysicl/numberarray.h"
43 #ifdef ANTIOCH_HAVE_VEXCL
44 #include "vexcl/vexcl.hpp"
63 #ifdef ANTIOCH_HAVE_GRVY
66 GRVY::GRVY_Timer_Class gt;
89 template <
typename PairScalars,
typename VectorPairScalar>
90 void make_custom(
unsigned int choice,
const PairScalars & ex, VectorPairScalar & x, VectorPairScalar & y)
97 x.resize(9,ex); y.resize(9,ex);
98 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
100 x[0][2*tuple] = 2.50L; y[0][2*tuple] = 2.25L/0.75L;
101 x[1][2*tuple] = 3.25L; y[1][2*tuple] = 3.75L/0.75L;
102 x[2][2*tuple] = 4.00L; y[2][2*tuple] = 6.00L/0.75L;
103 x[3][2*tuple] = 4.75L; y[3][2*tuple] = 5.00L/0.75L;
104 x[4][2*tuple] = 5.50L; y[4][2*tuple] = 5.50L/0.75L;
105 x[5][2*tuple] = 6.25L; y[5][2*tuple] = 7.50L/0.75L;
106 x[6][2*tuple] = 7.00L; y[6][2*tuple] = 5.25L/0.75L;
107 x[7][2*tuple] = 7.75L; y[7][2*tuple] = 3.75L/0.75L;
108 x[8][2*tuple] = 8.50L; y[8][2*tuple] = 0.00L/0.75L;
112 x[0][2*tuple + 1] = 0.00L; y[0][2*tuple + 1] = 0.50L/1.50L;
113 x[1][2*tuple + 1] = 1.50L; y[1][2*tuple + 1] = 2.50L/1.50L;
114 x[2][2*tuple + 1] = 3.00L; y[2][2*tuple + 1] = 9.00L/1.50L;
115 x[3][2*tuple + 1] = 4.50L; y[3][2*tuple + 1] = 10.0L/1.50L;
116 x[4][2*tuple + 1] = 6.00L; y[4][2*tuple + 1] = 13.5L/1.50L;
117 x[5][2*tuple + 1] = 7.50L; y[5][2*tuple + 1] = 7.50L/1.50L;
118 x[6][2*tuple + 1] = 9.00L; y[6][2*tuple + 1] = 2.00L/1.50L;
119 x[7][2*tuple + 1] = 10.5L; y[7][2*tuple + 1] = 0.00L/1.50L;
120 x[8][2*tuple + 1] = 12.0L; y[8][2*tuple + 1] = 0.00L/1.50L;
126 x.resize(5,ex); y.resize(5,ex);
127 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
129 x[0][2*tuple] = -1.00L; y[0][2*tuple] = 0.00L/1.20L;
130 x[1][2*tuple] = 0.20L; y[1][2*tuple] = 0.40L/1.20L;
131 x[2][2*tuple] = 1.40L; y[2][2*tuple] = 1.80L/1.20L;
132 x[3][2*tuple] = 2.60L; y[3][2*tuple] = 4.80L/1.20L;
133 x[4][2*tuple] = 3.80L; y[4][2*tuple] = 00.0L/1.20L;
136 x[0][2*tuple + 1] = 2.0000L; y[0][2*tuple + 1] = 8.50L/2.1875L;
137 x[1][2*tuple + 1] = 4.1875L; y[1][2*tuple + 1] = 16.25L/2.1875L;
138 x[2][2*tuple + 1] = 6.3750L; y[2][2*tuple + 1] = 15.50L/2.1875L;
139 x[3][2*tuple + 1] = 8.5625L; y[3][2*tuple + 1] = 3.75L/2.1875L;
140 x[4][2*tuple + 1] = 10.7500L; y[4][2*tuple + 1] = 0.00L/2.1875L;
148 template <
typename VectorScalar>
153 for(
unsigned int i = 0; i < 10; i++)
171 template <
typename PairScalars>
172 int vectester(
const PairScalars& example,
const std::string& testname)
176 std::vector<Scalar> bin_ref_x,bin_ref_y;
182 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 10;
186 #ifdef ANTIOCH_HAVE_GRVY
187 gt.BeginTimer(testname);
193 for(
unsigned int i = 0; i < 2; i++)
195 std::vector<PairScalars> bin_custom_x, exact_sol_y;
197 std::vector<PairScalars> bin_custom_y(bin_custom_x.size(),
Antioch::zero_clone(bin_custom_x[0]));
200 bin_custom_x,bin_custom_y);
203 for(
unsigned int il = 0; il < bin_custom_x.size() - 1; il++)
205 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
210 std::abs(bin_custom_y[il][2*tuple] - exact_sol_y[il][2*tuple]),
211 std::abs(bin_custom_y[il][2*tuple] - exact_sol_y[il][2*tuple])/exact_sol_y[il][2*tuple]);
214 std::cout << std::scientific << std::setprecision(16)
215 <<
"Error: Mismatch in bin values for " << testname << std::endl
216 <<
"case (" << bin_custom_x[il][2*tuple] <<
";" << bin_custom_x[il + 1][2*tuple] <<
")" << std::endl
217 <<
"bin = " << bin_custom_y[il][2*tuple] << std::endl
218 <<
"bin_exact = " << exact_sol_y[il][2*tuple] << std::endl
219 <<
"relative error = " << dist << std::endl
220 <<
"tolerance = " << tol << std::endl;
227 std::abs(bin_custom_y[il][2*tuple + 1] - exact_sol_y[il][2*tuple + 1]),
228 std::abs(bin_custom_y[il][2*tuple + 1] - exact_sol_y[il][2*tuple + 1])/exact_sol_y[il][2*tuple + 1]);
231 std::cout << std::scientific << std::setprecision(16)
232 <<
"Error: Mismatch in bin values for " << testname << std::endl
233 <<
"case (" << bin_custom_x[il][2*tuple + 1] <<
";" << bin_custom_x[il+1][2*tuple + 1] <<
")" << std::endl
234 <<
"bin = " << bin_custom_y[il][2*tuple + 1] << std::endl
235 <<
"bin_exact = " << exact_sol_y[il][2*tuple + 1] << std::endl
236 <<
"relative error = " << dist << std::endl
237 <<
"tolerance = " << tol << std::endl;
247 #ifdef ANTIOCH_HAVE_GRVY
248 gt.EndTimer(testname);
259 returnval = returnval ||
260 vectester (std::valarray<float>(2*ANTIOCH_N_TUPLES),
"valarray<float>");
261 returnval = returnval ||
262 vectester (std::valarray<double>(2*ANTIOCH_N_TUPLES),
"valarray<double>");
263 returnval = returnval ||
264 vectester (std::valarray<long double>(2*ANTIOCH_N_TUPLES),
"valarray<ld>");
266 #ifdef ANTIOCH_HAVE_EIGEN
267 returnval = returnval ||
268 vectester (Eigen::Array<float, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXf");
269 returnval = returnval ||
270 vectester (Eigen::Array<double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXd");
271 returnval = returnval ||
272 vectester (Eigen::Array<long double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXld");
274 #ifdef ANTIOCH_HAVE_METAPHYSICL
275 returnval = returnval ||
276 vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, float> (0),
"NumberArray<float>");
277 returnval = returnval ||
278 vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, double> (0),
"NumberArray<double>");
279 returnval = returnval ||
280 vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, long double> (0),
"NumberArray<ld>");
282 #ifdef ANTIOCH_HAVE_VEXCL
283 vex::Context ctx_f (vex::Filter::All);
285 returnval = returnval ||
286 vectester (vex::vector<float> (ctx_f, 2*ANTIOCH_N_TUPLES),
"vex::vector<float>");
288 vex::Context ctx_d (vex::Filter::DoublePrecision);
290 returnval = returnval ||
291 vectester (vex::vector<double> (ctx_d, 2*ANTIOCH_N_TUPLES),
"vex::vector<double>");
294 #ifdef ANTIOCH_HAVE_GRVY
void make_reference(VectorScalar &x, VectorScalar &y)
int vectester(const PairScalars &example, const std::string &testname)
enable_if_c< is_eigen< T1 >::value &&is_eigen< T2 >::value, typename state_type< T1 >::type >::type if_else(const Condition &condition, const T1 &if_true, const T2 &if_false)
void make_custom(unsigned int choice, const PairScalars &ex, VectorPairScalar &x, VectorPairScalar &y)
void y_on_custom_grid(const VectorCoeffType &x_old, const VectorCoeffType &y_old, const VectorStateType &x_new, VectorStateType &y_new) const
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)