37#include <boost/test/tools/floating_point_comparison.hpp>
38#include <boost/test/unit_test.hpp>
57double ddot(
int n,
double *x,
int incx,
double *y,
int incy)
84 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
int o)
95 for (
int n = 2; n < 2 * np - 1 - o; ++n)
98 double sum =
ddot(np, &
w[0], 1, &
p[0], 1);
99 BOOST_CHECK_SMALL(sum,
EPS);
119 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
120 std::function<
void(
double *,
double *,
int,
double,
double)> funcD)
131 funcD(&
d[0], &
z[0], np, alpha,
beta);
132 for (
int n = 2; n < np - 1; ++n)
134 for (
int i = 0; i < np; ++i)
141 for (
int i = 0; i < np; ++i)
143 sum += fabs(
ddot(np, &
d[0] + i, np, &
p[0], 1) -
144 n * pow(
z[i], n - 1));
148 BOOST_CHECK_SMALL(sum,
EPS);
168 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
169 std::function<
void(
double *,
double *,
double *,
int,
int,
double,
double)>
181 for (
int n = 2; n < np - 1; ++n)
183 for (
int i = 0; i < np; ++i)
185 w[i] = 2.0 * i / (double)(np - 1) - 1.0;
188 funcI(&
d[0], &
z[0], &
w[0], np, np, alpha,
beta);
191 for (
int i = 0; i < np; ++i)
193 sum += fabs(
ddot(np, &
d[0] + i, np, &
p[0], 1) -
198 BOOST_CHECK_SMALL(sum,
EPS);
208 std::function<
void(
double *,
double *,
int,
double,
double)>
func,
209 std::function<
void(
double *,
double *,
int)> funcQ)
220 funcQ(&
q[0], &
z[0], np);
221 for (
int n = 2; n < np - 1; ++n)
223 for (
int i = 0; i < np; ++i)
230 for (
int i = 0; i < np; ++i)
232 sum += fabs(
ddot(np, &
q[0] + i * np, 1, &
p[0], 1) -
233 pow(
z[i], n + 1) / (n + 1));
237 BOOST_CHECK_SMALL(sum,
EPS);
330 using arrT = std::tuple<int, double, int, double>;
331 std::vector<std::tuple<double, arrT, arrT>> ac = {
332 {362880.0, std::make_tuple(10, 0.0, 0, 1.0),
333 std::make_tuple(1, 0.0, 12, -2.0)},
334 {30.0, std::make_tuple(4, 3., 5, 0.), std::make_tuple(5, 0., 7, 0.)},
335 {21651.09375, std::make_tuple(7, 3.5, 5, 0.5),
336 std::make_tuple(5, 0.5, 10, 0.5)},
337 {97429.921875, std::make_tuple(10, 0.5, 5, -0.5),
338 std::make_tuple(5, -0.5, 11, -0.5)},
339 {2279.0625, std::make_tuple(10, -0.5, 5, 0.5),
340 std::make_tuple(5, 0.5, 10, -0.5)},
341 {639383.8623046875, std::make_tuple(10, 0.5, 0, 0.5),
342 std::make_tuple(0, 0.5, 10, 0.5)},
343 {5967498288235982848., std::make_tuple(100, 0., 90, 0.5),
344 std::make_tuple(90, 0.5, 100, 0.)},
345 {5618641603777298169856., std::make_tuple(200, 0., 191, -0.5),
346 std::make_tuple(190, 0.5, 200, 0.)},
347 {77396694214720029196288., std::make_tuple(200, 0., 190, 0.),
348 std::make_tuple(190, 0., 200, 0.)}};
350 for (
auto &
test : ac)
352 double a = std::get<0>(
test);
353 arrT c1 = std::get<1>(
test);
354 arrT c2 = std::get<2>(
test);
356 std::get<2>(c1), std::get<3>(c1));
358 std::get<2>(c2), std::get<3>(c2));
360 BOOST_CHECK_SMALL(c1e / a - 1.0,
EPS);
361 BOOST_CHECK_SMALL(c2e * a - 1.0,
EPS);
365 for (
double alpha = -0.5; alpha <= 150.; alpha += 0.5)
371 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)
The above copyright notice and this permission notice shall be included.
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, .