37#include <boost/test/tools/floating_point_comparison.hpp>
38#include <boost/test/unit_test.hpp>
55double ddot(
int n,
double *x,
int incx,
double *y,
int incy)
82 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
int o)
93 for (
int n = 2; n < 2 * np - 1 - o; ++n)
96 double sum =
ddot(np, &
w[0], 1, &
p[0], 1);
97 BOOST_CHECK_SMALL(sum,
EPS);
117 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
118 std::function<
void(
double *,
double *,
int,
double,
double)> funcD)
129 funcD(&
d[0], &
z[0], np, alpha,
beta);
130 for (
int n = 2; n < np - 1; ++n)
132 for (
int i = 0; i < np; ++i)
139 for (
int i = 0; i < np; ++i)
141 sum += fabs(
ddot(np, &
d[0] + i, np, &
p[0], 1) -
142 n * pow(
z[i], n - 1));
146 BOOST_CHECK_SMALL(sum,
EPS);
166 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
167 std::function<
void(
double *,
double *,
double *,
int,
int,
double,
double)>
179 for (
int n = 2; n < np - 1; ++n)
181 for (
int i = 0; i < np; ++i)
183 w[i] = 2.0 * i / (double)(np - 1) - 1.0;
186 funcI(&
d[0], &
z[0], &
w[0], np, np, alpha,
beta);
189 for (
int i = 0; i < np; ++i)
191 sum += fabs(
ddot(np, &
d[0] + i, np, &
p[0], 1) -
196 BOOST_CHECK_SMALL(sum,
EPS);
206 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
207 std::function<
void(
double *,
double *,
int)> funcQ)
218 funcQ(&
q[0], &
z[0], np);
219 for (
int n = 2; n < np - 1; ++n)
221 for (
int i = 0; i < np; ++i)
228 for (
int i = 0; i < np; ++i)
230 sum += fabs(
ddot(np, &
q[0] + i * np, 1, &
p[0], 1) -
231 pow(
z[i], n + 1) / (n + 1));
235 BOOST_CHECK_SMALL(sum,
EPS);
328 using arrT = std::tuple<int, double, int, double>;
329 std::vector<std::tuple<double, arrT, arrT>> ac = {
330 {362880.0, std::make_tuple(10, 0.0, 0, 1.0),
331 std::make_tuple(1, 0.0, 12, -2.0)},
332 {30.0, std::make_tuple(4, 3., 5, 0.), std::make_tuple(5, 0., 7, 0.)},
333 {21651.09375, std::make_tuple(7, 3.5, 5, 0.5),
334 std::make_tuple(5, 0.5, 10, 0.5)},
335 {97429.921875, std::make_tuple(10, 0.5, 5, -0.5),
336 std::make_tuple(5, -0.5, 11, -0.5)},
337 {2279.0625, std::make_tuple(10, -0.5, 5, 0.5),
338 std::make_tuple(5, 0.5, 10, -0.5)},
339 {639383.8623046875, std::make_tuple(10, 0.5, 0, 0.5),
340 std::make_tuple(0, 0.5, 10, 0.5)},
341 {5967498288235982848., std::make_tuple(100, 0., 90, 0.5),
342 std::make_tuple(90, 0.5, 100, 0.)},
343 {5618641603777298169856., std::make_tuple(200, 0., 191, -0.5),
344 std::make_tuple(190, 0.5, 200, 0.)},
345 {77396694214720029196288., std::make_tuple(200, 0., 190, 0.),
346 std::make_tuple(190, 0., 200, 0.)}};
348 for (
auto &
test : ac)
350 double a = std::get<0>(
test);
351 arrT c1 = std::get<1>(
test);
352 arrT c2 = std::get<2>(
test);
354 std::get<2>(c1), std::get<3>(c1));
356 std::get<2>(c2), std::get<3>(c2));
358 BOOST_CHECK_SMALL(c1e / a - 1.0,
EPS);
359 BOOST_CHECK_SMALL(c2e * a - 1.0,
EPS);
363 for (
double alpha = -0.5; alpha <= 150.; alpha += 0.5)
369 BOOST_CHECK_SMALL(c,
EPS);
#define NPUPPER
Upper range of number of quadrature points to use for unit tests.
#define EPS
Tolerance to be used for floating point comparisons.
#define NPLOWER
Lower range of number of quadrature points to use for unit tests.
@ beta
Gauss Radau pinned at x=-1,.
std::vector< double > w(NPUPPER)
std::vector< double > p(NPUPPER)
std::vector< double > z(NPUPPER)
void TestInterpolation(std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, double *, int, int, double, double)> funcI)
Evaluate interpolation using Gaussian quadrature.
std::vector< double > d(NPUPPER *NPUPPER)
double ddot(int n, double *x, int incx, double *y, int incy)
Dot product two vectors.
void TestIntegral(std::function< void(double *, double *, int, double, double)> func, int o)
Test integrals of Jacobi polynomials.
std::vector< double > q(NPUPPER *NPUPPER)
void TestIntegralMatrix(std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, int)> funcQ)
void TestDifferentiation(std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, int, double, double)> funcD)
Test derivatives using Gaussian quadrature.
BOOST_AUTO_TEST_CASE(TestGaussInt)
double gammaF(const double x)
Calculate the Gamma function , , for integer values and halves.
void Dgj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Jacobi zeros.
void zwgrjm(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=-1.
void zwgrjp(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=1.
void Dglj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Lobatto-Jacobi zeros.
void Imgrjp(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=1) to an arbitrary distrubtion at ...
void zwglj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Lobatto-Jacobi zeros and weights with end point at z=-1,1.
void zwgj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Jacobi zeros and weights.
void Imgj(double *im, const double *zgj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Jacobi points to an arbitrary distribution at points zm.
void Qg(double *Q, const double *z, const int np)
Compute the Integration Matrix.
double gammaFracGammaF(const int x, const double alpha, const int y, const double beta)
Calculate fraction of two Gamma functions, , for integer values and halves.
void Imgrjm(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=-1) to an arbitrary distrubtion at...
void Dgrjm(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Radau-Jacobi zeros with a z...
void Dgrjp(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Radau-Jacobi zeros with a zero at z=1.
void Imglj(double *im, const double *zglj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Lobatto-Jacobi points to an arbitrary distrubtion at points zm.
void jacobfd(const int np, const double *z, double *poly_in, double *polyd, const int n, const double alpha, const double beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .