PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::math::polynomial Namespace Reference

The namespace for the Polynomial module. More...

Classes

struct  DivergenceFreeBasis
 Divergence-free polynomial basis \( \left\{ \mathbf{P}_i(X) \; \text{s.t.} \; \nabla_X \mathbf{P}_i = 0 \right\} \) in dimensions \( d \) and order \( p \). More...
 
struct  MonomialBasis
 Polynomial basis \( \left\{ \Pi_{i=1}^{d} \mathbf{X}_i^{p_i} \; \text{s.t.} \; 0 \leq \sum_{i=1}^d p_i \leq p \right\} \) in dimensions \( d \) and order \( p \). More...
 
struct  OrthonormalBasis
 Orthonormal polynomial basis \( \left\{ P_i(X) \right\} \) in dimensions \( d \) and order \( p \). More...
 

Concepts

concept  CBasis
 
concept  CVectorBasis
 

Functions

template<auto N, class TScalar = Scalar>
bool HasRoot (std::array< TScalar, N+1 > const &coeffs, TScalar min=std::numeric_limits< TScalar >::lowest(), TScalar max=std::numeric_limits< TScalar >::max())
 Check if a polynomial has a root in the range [min,max].
 
template<auto N, class TScalar = Scalar>
std::array< TScalar, N > Roots (std::array< TScalar, N+1 > const &coeffs, TScalar min=std::numeric_limits< TScalar >::lowest(), TScalar max=std::numeric_limits< TScalar >::max())
 Computes all real roots of a degree N polynomial in the range [min,max].
 
template<auto N, class FOnRoot, class TScalar = Scalar>
bool ForEachRoot (FOnRoot &&fOnRoot, std::array< TScalar, N+1 > const &coeffs, TScalar min=std::numeric_limits< TScalar >::lowest(), TScalar max=std::numeric_limits< TScalar >::max())
 Computes the each real root of a degree N polynomial in the range [min,max] in increasing order.
 

Detailed Description

The namespace for the Polynomial module.

Function Documentation

◆ ForEachRoot()

template<auto N, class FOnRoot, class TScalar = Scalar>
bool pbat::math::polynomial::ForEachRoot ( FOnRoot && fOnRoot,
std::array< TScalar, N+1 > const & coeffs,
TScalar min = std::numeric_limits<TScalar>::lowest(),
TScalar max = std::numeric_limits<TScalar>::max() )
inline

Computes the each real root of a degree N polynomial in the range [min,max] in increasing order.

Note
We use the expensive but most accurate method from [16]
Template Parameters
NDegree of the polynomial.
FOnRootCallable type with signature bool(TScalar root).
TScalarScalar type of the polynomial.
Parameters
fOnRootCallable object to be called for each root. If the callable returns true, the iteration stops.
coeffsCoefficients of the polynomial.
minMinimum value of the search range.
maxMaximum value of the search range.
Returns
true if root finding is terminated by fOnRoot. Otherwise, returns false.

◆ HasRoot()

template<auto N, class TScalar = Scalar>
bool pbat::math::polynomial::HasRoot ( std::array< TScalar, N+1 > const & coeffs,
TScalar min = std::numeric_limits<TScalar>::lowest(),
TScalar max = std::numeric_limits<TScalar>::max() )
inline

Check if a polynomial has a root in the range [min,max].

Note
We use the expensive but most accurate method from [16]
Template Parameters
NThe degree of the polynomial.
TScalarThe scalar type of the polynomial.
Parameters
coeffsThe coefficients of the polynomial.
minThe minimum value of the search range.
maxThe maximum value of the search range.
Returns
true if the polynomial has a root, false otherwise.

◆ Roots()

template<auto N, class TScalar = Scalar>
std::array< TScalar, N > pbat::math::polynomial::Roots ( std::array< TScalar, N+1 > const & coeffs,
TScalar min = std::numeric_limits<TScalar>::lowest(),
TScalar max = std::numeric_limits<TScalar>::max() )
inline

Computes all real roots of a degree N polynomial in the range [min,max].

Note
We use the expensive but most accurate method from [16]
Template Parameters
NDegree of the polynomial.
TScalarScalar type of the polynomial.
Parameters
coeffsCoefficients of the polynomial.
minMinimum value of the search range.
maxMaximum value of the search range.
Returns
The roots of the polynomial at the head of the returned array, NaNs at the tail.