The OpenD Programming Language

gaussLobattoQuadrature

Gauss-Lobatto Quadrature

@safe pure nothrow @nogc
size_t
gaussLobattoQuadrature
(
T
)
(
scope T[] x
,
scope T[] w
,
scope T[] work
,
const T alpha = 0
,
const T beta = 0
)

Parameters

x T[]

(out) user-allocated quadrature nodes in ascending order length of N

w T[]

(out) user-allocated corresponding quadrature weights length of N

work T[]

(temp) user-allocated workspace length of greate or equal to N ^^ 2

alpha T

(optional) parameter '> -1'

beta T

(optional) parameter '> -1'

Return Value

Type: size_t

0 on success, xSTEQR LAPACK code on numerical error.

Examples

import mir.math.common;

auto n = 7;
auto x = new double[n];
auto w = new double[n];
auto work = new double[n ^^ 2];

gaussLobattoQuadrature(x, w, work);

static immutable xc =
   [-1,
    -sqrt(5.0 / 11 + 2.0 / 11 * sqrt(5.0 / 3)),
    -sqrt(5.0 / 11 - 2.0 / 11 * sqrt(5.0 / 3)),
     0.        ,
    +sqrt(5.0 / 11 - 2.0 / 11 * sqrt(5.0 / 3)),
    +sqrt(5.0 / 11 + 2.0 / 11 * sqrt(5.0 / 3)),
     1];

static immutable wc =
   [1.0 / 21,
    (124.0 - 7 * sqrt(15.0)) / 350,
    (124.0 + 7 * sqrt(15.0)) / 350,
    256.0 / 525,
    (124.0 + 7 * sqrt(15.0)) / 350,
    (124.0 - 7 * sqrt(15.0)) / 350,
    1.0 / 21];

foreach (i; 0 .. n)
    assert(x[i].approxEqual(xc[i]));
foreach (i; 0 .. n)
    assert(w[i].approxEqual(wc[i]));

Meta