ALFI
Advanced Library for Function Interpolation
|
Namespace providing support for rational functions. More...
Typedefs | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
using | RationalFunction = std::pair<Container<Number>, Container<Number>> |
Represents a rational function \(\displaystyle f(x) = \frac{A(x)}{B(x)}\), where \(A(x)\) and \(B(x)\) are polynomials. | |
Functions | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
std::enable_if_t<!traits::has_size< Number >::value, Number > | val_mul (const RationalFunction< Number, Container > &rf, const Number &x) |
Evaluates the rational function at a scalar point using Horner's method. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
std::enable_if_t< traits::has_size< Container< Number > >::value, Container< Number > > | val_mul (const RationalFunction< Number, Container > &rf, const Container< Number > &xx) |
Evaluates the rational function at each point in the container using val_mul for scalar values. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
std::enable_if_t<!traits::has_size< Number >::value, Number > | val_div (const RationalFunction< Number, Container > &rf, const Number &x) |
Evaluates the rational function at a scalar point by factoring out powers of x. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
std::enable_if_t< traits::has_size< Container< Number > >::value, Container< Number > > | val_div (const RationalFunction< Number, Container > &rf, const Container< Number > &xx) |
Evaluates the rational function at each point in the container using val_div for scalar values. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
std::enable_if_t<!traits::has_size< Number >::value, Number > | val (const RationalFunction< Number, Container > &rf, const Number &x) |
Evaluates the rational function at a scalar point. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
std::enable_if_t< traits::has_size< Container< Number > >::value, Container< Number > > | val (const RationalFunction< Number, Container > &rf, const Container< Number > &xx) |
Evaluates the rational function at each point in the container using val for scalar values. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
RationalFunction< Number, Container > | pade (Container< Number > P, SizeT n, SizeT m, const Number &epsilon=std::numeric_limits< Number >::epsilon()) |
Computes the [n / m ] Pade approximant of the polynomial P about the point \(x = 0\). | |
Namespace providing support for rational functions.
This namespace provides types and functions for representing, computing and evaluating rational functions of the form
\[ f(x) = \frac{A(x)}{B(x)} \]
where \(A(x)\) and \(B(x)\) are polynomials.
using alfi::ratf::RationalFunction = std::pair<Container<Number>, Container<Number>> |
Represents a rational function \(\displaystyle f(x) = \frac{A(x)}{B(x)}\), where \(A(x)\) and \(B(x)\) are polynomials.
A pair (std::pair
) of polynomials {.first as numerator, .second as denominator}
stored as containers of coefficients in descending degree order.
std::enable_if_t<!traits::has_size< Number >::value, Number > alfi::ratf::val_mul | ( | const RationalFunction< Number, Container > & | rf, |
const Number & | x ) |
Evaluates the rational function at a scalar point using Horner's method.
Computes \(f(x) = \frac{A(x)}{B(x)}\) by evaluating the values of the numerator \(A\) and the denominator \(B\) using Horner's method, and then dividing the results.
val utilizes this function for \(|x| \leq 1\).
std::enable_if_t< traits::has_size< Container< Number > >::value, Container< Number > > alfi::ratf::val_mul | ( | const RationalFunction< Number, Container > & | rf, |
const Container< Number > & | xx ) |
Evaluates the rational function at each point in the container using val_mul for scalar values.
std::enable_if_t<!traits::has_size< Number >::value, Number > alfi::ratf::val_div | ( | const RationalFunction< Number, Container > & | rf, |
const Number & | x ) |
Evaluates the rational function at a scalar point by factoring out powers of x.
Computes \(f(x) = \frac{A(x)}{B(x)}\) by evaluating both numerator and denominator in reverse order, effectively factoring out the dominant power of \(x\) to improve numerical stability for large \(|x|\).
val utilizes this function for \(|x| > 1\).
std::enable_if_t< traits::has_size< Container< Number > >::value, Container< Number > > alfi::ratf::val_div | ( | const RationalFunction< Number, Container > & | rf, |
const Container< Number > & | xx ) |
Evaluates the rational function at each point in the container using val_div for scalar values.
std::enable_if_t<!traits::has_size< Number >::value, Number > alfi::ratf::val | ( | const RationalFunction< Number, Container > & | rf, |
const Number & | x ) |
std::enable_if_t< traits::has_size< Container< Number > >::value, Container< Number > > alfi::ratf::val | ( | const RationalFunction< Number, Container > & | rf, |
const Container< Number > & | xx ) |
Evaluates the rational function at each point in the container using val for scalar values.
RationalFunction< Number, Container > alfi::ratf::pade | ( | Container< Number > | P, |
SizeT | n, | ||
SizeT | m, | ||
const Number & | epsilon = std::numeric_limits<Number>::epsilon() ) |
Computes the [n
/ m
] Pade approximant of the polynomial P
about the point \(x = 0\).
The Pade approximant is given by the formula
\[ P(x) = \frac{A(x)}{B(x)} = \frac{\sum_{i=0}^{n}{a_ix^i}}{b_0+\sum_{j=0}^{m}{b_jx^j}} \]
where \(A(x)\) and \(B(x)\) are the numerator and denominator polynomials, respectively; \(b_0 \neq 0\).
This function computes the Pade approximant of a polynomial by applying a modified extended Euclidean algorithm for polynomials.
The modification consists in that:
The latter is necessary to avoid false negatives, for example, when computing the [2/2]
approximant of the function \(x^5\).
Without the additional check, this also may lead to false positives, as in the case of computing the [2/2]
approximant of \(x^4\).
This is prevented by verifying that the constant term of the denominator is non-zero after the algorithm completes.
P | the polynomial to approximate (a container of coefficients in descending degree order) |
n | the maximum degree for the numerator |
m | the maximum degree for the denominator |
epsilon | the tolerance used to determine whether a coefficient is considered zero (default is machine epsilon) |
{numerator, denominator}
representing the Pade approximant; if an approximant does not exist, an empty pair is returned