Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
sw::math::polynomial Namespace Reference

Functions

template<typename Vector, typename Scalar>
void ddpoly (const Scalar &x, const Vector &c, Vector &pd)
template<typename Vector, typename Scalar>
Scalar polyeval (const Vector &coefficients, int n, const Scalar &x)
 polyeval evaluates a given n-th degree polynomial at x using Horner's rule.
template<typename Vector, typename Scalar>
Scalar polyroot (const Vector &c, const Scalar &x0, int max_iter, double threshold=1e-16)
 polyroot finds a root close to the initial guess x0.

Function Documentation

◆ ddpoly()

template<typename Vector, typename Scalar>
void sw::math::polynomial::ddpoly ( const Scalar & x,
const Vector & c,
Vector & pd )

◆ polyeval()

template<typename Vector, typename Scalar>
Scalar sw::math::polynomial::polyeval ( const Vector & coefficients,
int n,
const Scalar & x )
inline

polyeval evaluates a given n-th degree polynomial at x using Horner's rule.

The polynomial is given by the array of (n+1) coefficients.

Parameters
coefficientspolynomial coefficients
nportion of the polynomial to evaluate
xvalue to evaluate
Returns
polynomial at x

◆ polyroot()

template<typename Vector, typename Scalar>
Scalar sw::math::polynomial::polyroot ( const Vector & c,
const Scalar & x0,
int max_iter,
double threshold = 1e-16 )
inline

polyroot finds a root close to the initial guess x0.

Will only find a single root as it is using a Newton iteration

Parameters
cn-th degree polynomial
x0initial guess of the root of interest
max_iterstopping criterium
thresholdstopping cirterium
Returns
root closest to initial guess x0