mathtools.h File Reference

LibRPA: mathtools.h File Reference
LibRPA
mathtools.h File Reference

Basic mathematic tools for common tasks. More...

#include <cstddef>
Include dependency graph for mathtools.h:

Go to the source code of this file.

Functions

void GaussChebyshevI_unit (size_t N, double *nodes, double *weights)
 Get the Gauss-Chebyshev quadrature based on Chebyshev points of the first type (kind) More...
 
void GaussChebyshevII_unit (size_t N, double *nodes, double *weights)
 Get the Gauss-Chebyshev quadrature based on Chebyshev points of the second type (kind) More...
 
void GaussLegendre_unit (size_t N, double *nodes, double *weights)
 Compute N-point Gauss-Legendre grids in [-1, 1];. More...
 
void LegendreP_order_N (int N, double x, double &y, double &dy)
 Compute Legendre polynomial of order N at x in [-1, 1];. More...
 
void transform_GaussQuad_unit2x0inf (double x0, size_t N, double *nodes, double *weights)
 Transform Gauss grids from [-1, 1] to [x0, infty]. More...
 
void transform_GaussQuad_unit2x0x1 (double x0, double x1, size_t N, double *nodes, double *weights)
 Transform Gauss grids from [-1, 1] to [x0, x1]. More...
 
void transform_GaussQuad_unit2inf (size_t N, double *nodes, double *weights)
 Transform Gauss grids from [-1, 1] to [-infty, infty]. More...
 
void transform_GaussQuad_unit2minfx0 (double x0, size_t N, double *nodes, double *weights)
 Transform Gauss grids from [-1, 1] to [-infty, x0]. More...
 

Detailed Description

Basic mathematic tools for common tasks.

Note
Most functions are adapted from Gauss_Quadrature.cpp

Function Documentation

◆ GaussChebyshevI_unit()

void GaussChebyshevI_unit ( size_t  N,
double *  nodes,
double *  weights 
)

Get the Gauss-Chebyshev quadrature based on Chebyshev points of the first type (kind)

Parameters
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points

The nodes are zeros of order-N Chebyshev polynomials of first kind \(T_N(x)\) in \([-1,1]\):

\[ x_i = \cos(\frac{i + 0.5}{N}\pi) \]

The weight function is

\[ w(x) = \frac{1}{\sqrt{1-x^2}}. \]

with \(i = 0, 1, ..., N-1\).

Here is the caller graph for this function:

◆ GaussChebyshevII_unit()

void GaussChebyshevII_unit ( size_t  N,
double *  nodes,
double *  weights 
)

Get the Gauss-Chebyshev quadrature based on Chebyshev points of the second type (kind)

Parameters
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points

The nodes are the local extrema of T_N(x) in [-1,1]: x_i = cos( i*PI /(N+1) ) The weght function w(x_i) = PI/(N+1) *sin^2 ( x^2_i ), with i = 1, ..., N.

Here is the caller graph for this function:

◆ GaussLegendre_unit()

void GaussLegendre_unit ( size_t  N,
double *  nodes,
double *  weights 
)

Compute N-point Gauss-Legendre grids in [-1, 1];.

Parameters
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points
Here is the call graph for this function:

◆ LegendreP_order_N()

void LegendreP_order_N ( int  N,
double  x,
double &  y,
double &  dy 
)

Compute Legendre polynomial of order N at x in [-1, 1];.

Parameters
NOrder of polynomial
xGrid point to evaluate the polynomial
yValue of the polynomial at x
dyvalue of the derivative of polynomial at x

The following recurrence relation is used: for n = 1, 2, ..., N, nL_n(x) = (2n-1)xL_{n-1}(x) - (n-1)L_{n-2}(x) (x^2-1)L'n(x) = nxL_n(x) - nL{n-1}(x)

Here is the caller graph for this function:

◆ transform_GaussQuad_unit2inf()

void transform_GaussQuad_unit2inf ( size_t  N,
double *  nodes,
double *  weights 
)

Transform Gauss grids from [-1, 1] to [-infty, infty].

Parameters
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points

Transform from [-1,1] to [-inf,inf] x' = x/(1-x^2) wx' = (1+x^2)/(1-x^2)^2 *wx

◆ transform_GaussQuad_unit2minfx0()

void transform_GaussQuad_unit2minfx0 ( double  x0,
size_t  N,
double *  nodes,
double *  weights 
)

Transform Gauss grids from [-1, 1] to [-infty, x0].

Parameters
x0right end of the targeted region
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points

Transform from [-1,1] to [-inf,x0] wx' = 1 / (1+x)^2 *wx x' = 0.5 * (x-1)/(1+x) + x0

◆ transform_GaussQuad_unit2x0inf()

void transform_GaussQuad_unit2x0inf ( double  x0,
size_t  N,
double *  nodes,
double *  weights 
)

Transform Gauss grids from [-1, 1] to [x0, infty].

Parameters
x0Left end of the targeted region
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points
Here is the caller graph for this function:

◆ transform_GaussQuad_unit2x0x1()

void transform_GaussQuad_unit2x0x1 ( double  x0,
double  x1,
size_t  N,
double *  nodes,
double *  weights 
)

Transform Gauss grids from [-1, 1] to [x0, x1].

Parameters
x0Left end of the targeted region
x1Right end of the targeted region
NNumber of grid points
nodesLocations of grid points
weightsWeights of grid points

Transform from [-1,1] to [x0,x1] x' = (x1-x0)/2 *x + (x0+x1)/2 wx' = (x1-x0)/2 *wx