18 throw std::runtime_error(
19 "n_points in GaussLobattoLegendre must be at least 2.");
26 for (
auto i = 1; i <
abscissas.size() - 1; i++)
27 abscissas[i] = legendre_derivative_roots[i - 1];
34 for (
auto i = 0; i <
n_points; i++) {
35 for (
auto k = 0; k <
n_points; k++) {
45 double abscissa_difference = abscissa_i - abscissa_k;
55 double double_n =
static_cast<double>(n);
56 double leading_coefficient = 2.0 / (double_n * (double_n - 1.0));
58 double weight = leading_coefficient / legendre_weight / legendre_weight;
63 const std::valarray<double>& grid_function_vals) {
64 assert(grid_function_vals.size() ==
abscissas_.size());
66 for (
auto i = 0; i < grid_function_vals.size(); i++)
std::vector< double > lagrange_derivatives_
Derivatives of the Lagrange polynomials at the GLL nodes. These are stored as a flattened array and a...
double ComputeWeight(const size_t k, const size_t n) override
Computes the weights for a Gauss-Legendre-Lobatto quadrature scheme using:
std::vector< double > ComputeAbscissas(const size_t n_points)
Computes the abscissa values, given by:
GaussLobattoLegendre(const size_t n_points)
Construct a new GaussLobattoLegendre object.
void ComputeLagrangeDerivatives()
Computes and sets the Lagrange polynomial derivatives at the GLL nodes. The vector lagrange_derivativ...
double IntegrateGridFunction(const std::valarray< double > &grid_function_vals)
Integrate a function defined on the abscissae given in the order the abscissae are stored.
const std::vector< double > & abscissas() const
std::map< unsigned int, double > weight_map_
std::vector< double > abscissas_
std::vector< double > AllLegendrePrimeRoots(const int n)
Computes all roots of the polynomial. A total of n-1 roots will be computed and returned.
double LegendrePolynomial(const int n, const double x)
Computes the Legendre polynomial of degree n at a point x using the formula: