CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::glob::LegendrePolynomials Class Reference

The class LegendrePolynomials. More...

#include "Headers/LegendrePolynomials.h"

Public Member Functions

void set (const int lMax)
 set maximum order of expansion More...
 
double operator() (const double x, const int ell)
 evaluate the Legendre polynomial of order ell at x More...
 
std::vector< double > operator() (const double x)
 evaluate the Legendre polynomial up to lMax at x More...
 
double integral (const double x_min, const double x_max, const int ell)
 evaluate the bin-averaged Legendre polynomial of order ell More...
 
std::vector< double > integral (const double x_min, const double x_max)
 evaluate the bin-averaged Legendre polynomials More...
 
std::vector< std::vector< double > > triangle (const double r12, const double r13, const double r23)
 evaluate the Legendre polynomials for triangle angles. More...
 
std::vector< double > triangle_integral (const double r12_min, const double r12_max, const double r13_min, const double r13_max, const double r23_min, const double r23_max, const double rel_err=1.e-4, const int nevals=10000)
 evaluate the bin-averaged Legendre polynomials over a triangle. Triangle side can vary from a minimum to a maximum value More...
 
Constructors/destructors
 LegendrePolynomials ()
 Default constructor of LegendrePolynomials.
 
 LegendrePolynomials (const int lMax, const bool safe=false)
 Constructor of LegendrePolynomials. More...
 
 ~LegendrePolynomials ()
 Default destructor.
 

Protected Member Functions

void m_set_coefficients (const int lMax)
 set internal attribute m_coefficients More...
 

Protected Attributes

size_t m_nOrders
 Number of Legendre polynomial.
 
Eigen::MatrixXd m_coefficients
 Coefficients of the Legendre polynomials.
 

Detailed Description

The class LegendrePolynomials.

This class is used to handle Legendre polynomials. It contains all methods to compute Legendre polynomials as well as their integrals.

Definition at line 52 of file LegendrePolynomials.h.

Constructor & Destructor Documentation

◆ LegendrePolynomials()

cbl::glob::LegendrePolynomials::LegendrePolynomials ( const int  lMax,
const bool  safe = false 
)

Constructor of LegendrePolynomials.

Parameters
lMaxmaximum order of Legendre polynomials
safeTrue \(\rightarrow \) check input range is among -1 a 1 False \( \rightarrow \) do not check input

Definition at line 88 of file LegendrePolynomials.cpp.

Member Function Documentation

◆ integral() [1/2]

vector< double > cbl::glob::LegendrePolynomials::integral ( const double  x_min,
const double  x_max 
)

evaluate the bin-averaged Legendre polynomials

Parameters
x_minthe lower bin edge
x_maxthe up bin edge
Returns
the bin-averaged Legendre polynomials

Definition at line 167 of file LegendrePolynomials.cpp.

◆ integral() [2/2]

double cbl::glob::LegendrePolynomials::integral ( const double  x_min,
const double  x_max,
const int  ell 
)

evaluate the bin-averaged Legendre polynomial of order ell

Parameters
x_minthe lower bin edge
x_maxthe up bin edge
ellthe order of the Legendre polynomial
Returns
the bin-averaged Legendre polynomial of order ell

Definition at line 144 of file LegendrePolynomials.cpp.

◆ m_set_coefficients()

void cbl::glob::LegendrePolynomials::m_set_coefficients ( const int  lMax)
protected

set internal attribute m_coefficients

Set the coefficients of the Legendre Polynomials according to the following recursive relation:

\[ P_{n}(x)=2^{n} \sum_{k=0}^{n} x^{k}\left(\begin{array}{l} n \\ k \end{array}\right)\left(\begin{array}{c} \frac{n+k-1}{2} \\ n \end{array}\right) \]

Parameters
lMaxmaximum order of Legendre polynomials

Definition at line 48 of file LegendrePolynomials.cpp.

◆ operator()() [1/2]

vector< double > cbl::glob::LegendrePolynomials::operator() ( const double  x)

evaluate the Legendre polynomial up to lMax at x

Parameters
xthe point to evaluate Legendre polynomials
Returns
vector containing the Legendre polynomials at x

Definition at line 124 of file LegendrePolynomials.cpp.

◆ operator()() [2/2]

double cbl::glob::LegendrePolynomials::operator() ( const double  x,
const int  ell 
)

evaluate the Legendre polynomial of order ell at x

Parameters
xthe point to evaluate Legendre polynomial
ellthe order of the Legendre polynomial
Returns
the Legendre polynomial of order ell at x

Definition at line 107 of file LegendrePolynomials.cpp.

◆ set()

void cbl::glob::LegendrePolynomials::set ( const int  lMax)

set maximum order of expansion

Parameters
lMaxmaximum order of Legendre polynomials

Definition at line 98 of file LegendrePolynomials.cpp.

◆ triangle()

vector< vector< double > > cbl::glob::LegendrePolynomials::triangle ( const double  r12,
const double  r13,
const double  r23 
)

evaluate the Legendre polynomials for triangle angles.

Parameters
r12first triangle side
r13second triangle side
r23third triangle side
Returns
the Legendre polynomials averaged over a triangle

Definition at line 192 of file LegendrePolynomials.cpp.

◆ triangle_integral()

vector< double > cbl::glob::LegendrePolynomials::triangle_integral ( const double  r12_min,
const double  r12_max,
const double  r13_min,
const double  r13_max,
const double  r23_min,
const double  r23_max,
const double  rel_err = 1.e-4,
const int  nevals = 10000 
)

evaluate the bin-averaged Legendre polynomials over a triangle. Triangle side can vary from a minimum to a maximum value

Parameters
r12_minthe first side lower edge
r12_maxthe first side upper edge
r13_minthe second side lower edge
r13_maxthe second side upper edge
r23_minthe third side lower edge
r23_maxthe third side upper edge
rel_errthe relative integration error
nevalsmaximum number of function evaluation
Returns
the Legendre polynomials averaged over a triangle

Definition at line 210 of file LegendrePolynomials.cpp.


The documentation for this class was generated from the following files: