Namespace astrea::math¶
Namespace List > astrea > math
Public Functions¶
| Type | Name |
|---|---|
| constexpr mp_units::quantity< mp_units::one, Rep > | assoc_legendre (const unsigned int & n, const unsigned int & m, const mp_units::quantity< R, Rep > & q) noexcept |
| T | atan3 (T y, T x) |
| mp_units::QuantityOf< mp_units::dimensionless > auto | cosh (const mp_units::quantity< R, Rep > & q) noexcept |
| constexpr mp_units::quantity< mp_units::one, Rep > | cyl_bessel_j (const Rep & nu, const mp_units::quantity< R, Rep > & q) noexcept |
| double | evaluate_chebyshev_derivative (double x, double lb, double ub, const std::array< double, N > & coeff, double extrapolationTol=1.0e-6) Evaluate the derivative of the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula. |
| double | evaluate_chebyshev_derivative (double x, const std::array< double, N > & boundsCoeff, double extrapolationTol=1.0e-6) Evaluate the derivative of the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula. |
| double | evaluate_chebyshev_polynomial (const double & x, const double & lb, const double & ub, const std::array< double, N > & coeff, const double & coeffZeroFactor=0.5, const double & extrapolationTol=1.0e-6) Evaluate the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula. |
| double | evaluate_chebyshev_polynomial (const double & x, const std::array< double, N > & boundsCoeff, const double & coeffZeroFactor=0.5, const double & extrapolationTol=1.0e-6) Evaluate the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula. |
| Y | fast_interpolate (const std::array< X, 2 > & x, const std::array< Y, 2 > & y, const X & sx) Fast linear interpolation for two points, with bounds checking. |
| Y | interpolate (const std::vector< X > & x, const std::vector< Y > & y, const X & sx) Linear interpolation for a single point, with bounds checking. |
| mp_units::quantity< R, Rep > | max (const mp_units::quantity< R, Rep > & q1, const mp_units::quantity< R, Rep > & q2) noexcept |
| mp_units::quantity< R, Rep > | min (const mp_units::quantity< R, Rep > & q1, const mp_units::quantity< R, Rep > & q2) noexcept |
| constexpr bool | nearly_equal (const mp_units::quantity< R1, Rep > & x, const mp_units::quantity< R2, Rep > & y, const mp_units::quantity< mp_units::one, Rep > & relTol=0.0 *mp_units::one, const mp_units::quantity< mp_units::one, Rep > & absTol=0.0 *mp_units::one) noexcept Check if two quantities of the same unit are nearly equal within a relative tolerance. |
| mp_units::quantity< mp_units::one, Rep > | pow (const mp_units::quantity< R, Rep > & q, const mp_units::quantity< R, Rep > & n) noexcept |
| requires | requires (Rep v) Computes the sinc function for a given angle in radians. |
| mp_units::QuantityOf< mp_units::dimensionless > auto | sinc (const mp_units::quantity< R, Rep > & q) noexcept |
| mp_units::QuantityOf< mp_units::dimensionless > auto | sinh (const mp_units::quantity< R, Rep > & q) noexcept |
| double | transform_from_chebyshev_range (const double & x, const double & lb, const double & ub) Transform variable from the Chebyshev range of [-1, 1] to the range [lb, ub]. |
| double | transform_to_chebyshev_range (const double & x, const double & lb, const double & ub) Transform variable from the range [lb, ub] to the Chebyshev range of [-1, 1]. |
Public Functions Documentation¶
function assoc_legendre¶
constexpr mp_units::quantity< mp_units::one, Rep > astrea::math::assoc_legendre (
const unsigned int & n,
const unsigned int & m,
const mp_units::quantity< R, Rep > & q
) noexcept
function atan3¶
function cosh¶
inline mp_units::QuantityOf< mp_units::dimensionless > auto astrea::math::cosh (
const mp_units::quantity< R, Rep > & q
) noexcept
function cyl_bessel_j¶
constexpr mp_units::quantity< mp_units::one, Rep > astrea::math::cyl_bessel_j (
const Rep & nu,
const mp_units::quantity< R, Rep > & q
) noexcept
function evaluate_chebyshev_derivative¶
Evaluate the derivative of the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula.
template<size_t N>
double astrea::math::evaluate_chebyshev_derivative (
double x,
double lb,
double ub,
const std::array< double, N > & coeff,
double extrapolationTol=1.0e-6
)
Numerical Recipes in Fortran 77: The Art of Scientific Computing, Page 189, Routine chder
Parameters:
xValue at which the Chebyshev polynomial is to be evaluated atlbLower bound of the function rangeubUpper bound of the function rangecoeffChebyshev coefficients evaluated using chebyshev_coefficients functionextrapolationTolTolerance for the maximum distance x can be outside of [lb, ub] range before exception is thrown.
Returns:
Corresponding Chebyshev coefficient values
Template parameters:
NSize of the array
Exception:
std::invalid_argumentIf coeff has less than one value, or if extrapolation occurs
function evaluate_chebyshev_derivative¶
Evaluate the derivative of the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula.
template<size_t N>
double astrea::math::evaluate_chebyshev_derivative (
double x,
const std::array< double, N > & boundsCoeff,
double extrapolationTol=1.0e-6
)
Note:
The lb, ub, and Chebyshev coefficients are stored in the same array here, which is used for planetary coefficients from CSpice
Numerical Recipes in Fortran 77: The Art of Scientific Computing, Page 189, Routine chder
Parameters:
xValue at which the Chebyshev polynomial is to be evaluated atboundsCoeffVector containing lb, ub, and Chebyshev coefficients evaluated using chebyshev_coefficients functionextrapolationTolTolerance for the maximum distance x can be outside of [lb, ub] range before exception is thrown.
Returns:
Corresponding Chebyshev coefficient values
Template parameters:
NSize of the array
Exception:
std::invalid_argumentIf coeff has less than one value, or if extrapolation occurs
function evaluate_chebyshev_polynomial¶
Evaluate the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula.
template<std::size_t N>
double astrea::math::evaluate_chebyshev_polynomial (
const double & x,
const double & lb,
const double & ub,
const std::array< double, N > & coeff,
const double & coeffZeroFactor=0.5,
const double & extrapolationTol=1.0e-6
)
Numerical Recipes in Fortran 77: The Art of Scientific Computing, Page 187-188, Routine chebev
Parameters:
xValue at which the Chebyshev polynomial is to be evaluated atlbLower bound of the function rangeubUpper bound of the function rangecoeffChebyshev coefficients evaluated using chebyshev_coefficients functioncoeffZeroFactorFactor to multiply coeff[0] by. Numerical Recipes has this at 0.5, but for CSpice the coeff[0] has already been multiplied by 0.5, so set factor to 1.0extrapolationTolTolerance for the maximum distance x can be outside of [lb, ub] range before exception is thrown.
Returns:
Corresponding Chebyshev coefficient values
Template parameters:
NSize of the array
Exception:
std::invalid_argumentIf coeff has less than one value, or if extrapolation occurs
function evaluate_chebyshev_polynomial¶
Evaluate the Chebyshev polynomial at the specified value, x, which must be in the range [lb, ub], using Clenshaw's recurrence formula.
template<std::size_t N>
double astrea::math::evaluate_chebyshev_polynomial (
const double & x,
const std::array< double, N > & boundsCoeff,
const double & coeffZeroFactor=0.5,
const double & extrapolationTol=1.0e-6
)
Note:
The lb, ub, and Chebyshev coefficients are stored in the same array here, which is used for planetary coefficients from CSpice
Numerical Recipes in Fortran 77: The Art of Scientific Computing, Page 187-188, Routine chebev
Parameters:
xValue at which the Chebyshev polynomial is to be evaluated atboundsCoeffArray containing lb, ub, and Chebyshev coefficients evaluated using chebyshev_coefficients functioncoeffZeroFactorFactor to multiply coeff[0] by. Numerical Recipes has this at 0.5, but for CSpice the coeff[0] has already been multiplied by 0.5, so set factor to 1.0extrapolationTolTolerance for the maximum distance x can be outside of [lb, ub] range before exception is thrown.
Returns:
Corresponding Chebyshev coefficient values
Template parameters:
NSize of the array
Exception:
std::invalid_argumentIf coeff has less than one value, or if extrapolation occurs
function fast_interpolate¶
Fast linear interpolation for two points, with bounds checking.
template<typename X, typename Y>
inline Y astrea::math::fast_interpolate (
const std::array< X, 2 > & x,
const std::array< Y, 2 > & y,
const X & sx
)
Template parameters:
XType of the x values (e.g. time).YType of the y values (e.g. distance, angle). Must support arithmetic operations.
Parameters:
xTwo x values corresponding to the y values. Must be in ascending order.yTwo y values corresponding to the x values.sxThe x value to interpolate at. Must be between x[0] and x[1].
Returns:
Y The interpolated y value at sx.
Exception:
std::runtime_errorif sx is outside the bounds of x.
function interpolate¶
Linear interpolation for a single point, with bounds checking.
template<typename X, typename Y>
inline Y astrea::math::interpolate (
const std::vector< X > & x,
const std::vector< Y > & y,
const X & sx
)
Template parameters:
XType of the x values (e.g. time).YType of the y values (e.g. distance, angle). Must support arithmetic operations.
Parameters:
xVector of x values corresponding to the y values. Must be in ascending order.yVector of y values corresponding to the x values.sxThe x value to interpolate at. Must be between x[0] and x.back().
Returns:
Y The interpolated y value at sx.
Exception:
std::runtime_errorif sx is outside the bounds of x.
function max¶
inline mp_units::quantity< R, Rep > astrea::math::max (
const mp_units::quantity< R, Rep > & q1,
const mp_units::quantity< R, Rep > & q2
) noexcept
function min¶
inline mp_units::quantity< R, Rep > astrea::math::min (
const mp_units::quantity< R, Rep > & q1,
const mp_units::quantity< R, Rep > & q2
) noexcept
function nearly_equal¶
Check if two quantities of the same unit are nearly equal within a relative tolerance.
template<auto R1, auto R2, typename Rep>
constexpr bool astrea::math::nearly_equal (
const mp_units::quantity< R1, Rep > & x,
const mp_units::quantity< R2, Rep > & y,
const mp_units::quantity< mp_units::one, Rep > & relTol=0.0 *mp_units::one,
const mp_units::quantity< mp_units::one, Rep > & absTol=0.0 *mp_units::one
) noexcept
Template parameters:
RThe unit type (e.g., distance, time).RepThe representation type (e.g., double).
Parameters:
xFirst quantity to compare.ySecond quantity to compare.relTolRelative tolerance for comparison.
Returns:
true if the two quantities are nearly equal within the specified tolerance.
Returns:
false if they are not nearly equal.
function pow¶
inline mp_units::quantity< mp_units::one, Rep > astrea::math::pow (
const mp_units::quantity< R, Rep > & q,
const mp_units::quantity< R, Rep > & n
) noexcept
function requires¶
Computes the sinc function for a given angle in radians.
Computes the associated Legendre function of the first kind.
Computes the Bessel function of the first kind of order zero.
Computes the hyperbolic sine of a given angle in radians.
Computes the hyperbolic cosine of a given angle in radians.
The sinc function is defined as sin(x)/x, where x is in radians. This function handles both integral and floating-point types.
Template parameters:
RThe reference type for the angle (e.g., radian).RepThe representation type (e.g., double, float).
Parameters:
qThe angle in radians.
Returns:
The value of the sinc function at the given angle.
Template parameters:
RThe reference type for the angle (e.g., radian).RepThe representation type (e.g., double, float).
Parameters:
qThe angle in radians.
Returns:
The value of the hyperbolic cosine at the given angle.
Template parameters:
RThe reference type for the angle (e.g., radian).RepThe representation type (e.g., double, float).
Parameters:
qThe angle in radians.
Returns:
The value of the hyperbolic sine at the given angle.
This function computes the Bessel function of the first kind of order zero for a given value. It is defined as J_0(x) = (1/π) ∫_0^π cos(x sin(θ)) dθ.
Template parameters:
RThe reference type for the input value (e.g., dimensionless).RepThe representation type (e.g., double, float).
Parameters:
qThe input value.
Returns:
The value of the Bessel function of the first kind of order zero at the given input.
This function computes the associated Legendre function P_n^m(x) for given n, m, and x. It is defined as P_n^m(x) = (1/2^n n!) (d/dx)^n ((1 - x^2)^n) P_m^n(x).
Template parameters:
RThe reference type for the input value (e.g., dimensionless).RepThe representation type (e.g., double, float).
Parameters:
nThe degree of the polynomial.mThe order of the polynomial.qThe input value.
Returns:
The value of the associated Legendre function at the given input.
function sinc¶
inline mp_units::QuantityOf< mp_units::dimensionless > auto astrea::math::sinc (
const mp_units::quantity< R, Rep > & q
) noexcept
function sinh¶
inline mp_units::QuantityOf< mp_units::dimensionless > auto astrea::math::sinh (
const mp_units::quantity< R, Rep > & q
) noexcept
function transform_from_chebyshev_range¶
Transform variable from the Chebyshev range of [-1, 1] to the range [lb, ub].
double astrea::math::transform_from_chebyshev_range (
const double & x,
const double & lb,
const double & ub
)
Numerical Recipes in Fortran 77: The Art of Scientific Computing, Page 186, Eq. 5.8.10
Parameters:
xVariable in the Chebyshev rangelbLower bound of the function rangeubUpper bound of the function range
Returns:
Variable in the range [lb, ub]
function transform_to_chebyshev_range¶
Transform variable from the range [lb, ub] to the Chebyshev range of [-1, 1].
double astrea::math::transform_to_chebyshev_range (
const double & x,
const double & lb,
const double & ub
)
Numerical Recipes in Fortran 77: The Art of Scientific Computing, Page 186, Eq. 5.8.10
Parameters:
xVariable in the range [lb, ub]lbLower bound of the function rangeubUpper bound of the function range
Returns:
Variable in the Chebyshev range [-1, 1]
The documentation for this class was generated from the following file astrea/math/math/chebyshev_util.cpp