21 #include "marley/marley_utils.hh"
26 constexpr
size_t DEFAULT_N_CHEBYSHEV = 64u;
35 double x_min,
double x_max,
size_t N = 0);
43 for (
size_t j = 0; j <=
N_; ++j ) {
45 double x_j =
Xs_.at( j );
46 double f_j =
Fs_.at( j );
50 if ( x_j == x )
return f_j;
52 double temp = w_j / ( x - x_j );
53 if ( j == 0 || j ==
N_ ) temp /= 2.;
58 double px = numer / denom;
64 inline double integral()
const {
return integral_; };
66 inline const std::vector<double>& chebyshev_coeffs()
const
69 inline const std::vector<double>& Fs()
const
72 inline const std::vector<double>& Xs()
const
75 inline int N()
const {
return N_; }
85 static constexpr
size_t N_MAX_ = 65536u;
109 std::vector<double> wsave_;
110 std::vector<int> ifac_;
118 double x = std::cos(
static_cast<double>(marley_utils::pi * j) /
N_ );
124 void compute_integral();
Approximate representation of a 1D continuous function.
Definition: ChebyshevInterpolatingFunction.hh:29
double x_min_
Lower edge of the grid.
Definition: ChebyshevInterpolatingFunction.hh:91
double integral_
Approximate integral of the function on [x_min_, x_max_].
Definition: ChebyshevInterpolatingFunction.hh:97
static constexpr size_t N_MAX_
Maximum allowed value of the grid size parameter.
Definition: ChebyshevInterpolatingFunction.hh:85
double x_max_
Upper edge of the grid.
Definition: ChebyshevInterpolatingFunction.hh:94
size_t N_
Grid size parameter (N + 1 total points)
Definition: ChebyshevInterpolatingFunction.hh:88
ChebyshevInterpolatingFunction()
Default constructor used by cdf()
Definition: ChebyshevInterpolatingFunction.hh:82
double chebyshev_point(size_t j) const
For a given N, returns the x position of the jth Chebyshev point (of the second kind)
Definition: ChebyshevInterpolatingFunction.hh:116
double evaluate(double x) const
Approximates the represented function using the barycentric formula.
Definition: ChebyshevInterpolatingFunction.hh:39
std::vector< double > Xs_
Chebyshev points at which the function was evaluated.
Definition: ChebyshevInterpolatingFunction.hh:100
std::vector< double > chebyshev_coeffs_
Coefficients of the Chebyshev expansion of this function.
Definition: ChebyshevInterpolatingFunction.hh:106
std::vector< double > Fs_
Function values at the grid points.
Definition: ChebyshevInterpolatingFunction.hh:103