Core 1.0
Quintic Class Reference

Quintic polynomials. More...

#include <quintic.h>

Public Member Functions

 Quintic ()
 Empty.
 Quintic (const double &, const double &, const double &, const double &, const double &, const double &)
 Creates a quintic polynomial.
 Quintic (const Quadric &)
 Creates a quintic from a quadric.
 Quintic (const Cubic &)
 Creates a quintic from a cubic.
 Quintic (const Quartic &)
 Creates a quintic from a quartic.
 ~Quintic ()
 Empty.
constexpr double & operator[] (int)
 Access to the coefficients of the quintic.
constexpr double operator[] (int) const
 Overloaded.
int CheckDegree () const
 Check the degree of the quintic.
Quintic operator- () const
 Unary.
Quintic & operator+= (const Quintic &)
 Destructive sum.
Quintic & operator-= (const Quintic &)
 Destructive difference.
Quintic & operator*= (const double &)
 Scale.
Quintic & operator/= (const double &)
 Scale.
Quartic Prime () const
 Computes the first derivative of a quintic, which is a quartic.
Cubic Second () const
 Computes the second derivative of a quintic, which is a cubic.
Quadric Third () const
 Computes the third derivative of a quintic.
double K (const double &, const double &) const
 Compute the Lipschitz constant of the quintic.
constexpr double operator() (const double &) const
 Evaluates the quintic.
constexpr double Derivative (const double &) const
 Computes the derivative value at a given point.
int Solve (double *) const
 Solve the quintic equation.
int Solve (double *, const double &, const double &) const
 Search the roots of a quintic equation over a given interval.
void Range (double &, double &, const double &=0.0, const double &=1.0) const
 Compute the range of values taken by a quintic over a given interval.

Static Public Member Functions

static Quintic Hermite (const double &, const double &, const double &, const double &, const double &, const double &)
 Creates an Hermite quintic polynomial on interval [0,1].
static Quintic Bezier (const double &, const double &, const double &, const double &, const double &, const double &)
 Creates a quintic Bezier polynomial.
static double Smooth (const double &)
 Compute the value of smooth \( C^2 \) interpolating function over unit interval.
static double SmoothCompact (const double &, const double &)
 Compactly supported smooth interpolating function.
static double SmoothStep (const double &, const double &, const double &)
 Compute a quintic smooth step.
static double Gaussian (const double &, const double &, const double &)
 Compute a compactly supported Gaussian-like pulse.
static double GaussianThick (const double &, const double &, const double &, const double &)
 Compute a compactly supported Gaussian-like pulse with a thick plateau.
static Quintic FromRoots (const QVector< double > &)
 Create a quintic from a set of roots.

Static Public Attributes

static const double epsilon = 1.0e-10
 \( \varepsilon \) value used to check discriminant terms in the root finding process.

Protected Attributes

double c [6] = { 0.0,0.0,0.0,0.0,0.0,0.0 }
 Array of coefficients.

Friends

Quintic operator+ (const Quintic &u, const Quintic &v)
 Overloaded.
Quintic operator- (const Quintic &v, const Quintic &u)
 Overloaded.
Quintic operator* (const Quintic &u, const double &e)
 Overloaded.
Quintic operator* (const double &a, const Quintic &p)
 Overloaded.
Quintic operator/ (const Quintic &p, const double &a)
 Overloaded.
std::ostream & operator<< (std::ostream &s, const Quintic &p)
 Overloaded output-stream operator.

Detailed Description

Quintic polynomials.

Closed form expression of roots does not exist for polynomials of degree five or greater.

Constructors should provide the coefficients in descending order. Example of how to code the quintic \( x^5 - x + 1 \):

Quintic p(1.0,0.0,0.0,0.0,-1.0,1.0);
Quintic()
Empty.
Definition quintic.h:12

Quintic implements some inline static member function such as:

inline double Quintic::Smooth(const double& x)
{
return x * x * x * (x * (x * 6 - 15) + 10);
}
static double Smooth(const double &)
Compute the value of smooth interpolating function over unit interval.
Definition quintic.h:245

Constructor & Destructor Documentation

◆ Quintic() [1/3]

Quintic::Quintic ( const Quadric & p)
inline

Creates a quintic from a quadric.

Simply set higher coefficients to 0.

Parameters
pQuadric.

◆ Quintic() [2/3]

Quintic::Quintic ( const Cubic & p)
inline

Creates a quintic from a cubic.

Simply set higher coefficients to 0.

Parameters
pCubic.

◆ Quintic() [3/3]

Quintic::Quintic ( const Quartic & p)
inline

Creates a quintic from a quartic.

Parameters
pQuartic.

Member Function Documentation

◆ Bezier()

Quintic Quintic::Bezier ( const double & a,
const double & b,
const double & c,
const double & d,
const double & e,
const double & f )
static

Creates a quintic Bezier polynomial.

Interval parameterization is unit.

Parameters
a,b,c,d,e,fControl values.

◆ Derivative()

double Quintic::Derivative ( const double & x) const
inlineconstexpr

Computes the derivative value at a given point.

If only one evaluation is to be made, this function is more efficient than Prime() and then evaluating the derivative for a given input value.

Parameters
xReal.
See also
Quintic::Prime

◆ FromRoots()

Quintic Quintic::FromRoots ( const QVector< double > & r)
static

Create a quintic from a set of roots.

Parameters
rSet of roots.

Example of how to code the quintic \( (x-1)^3 (x+1) (x+2) \):

Quintic p=Quintic::FromRoots({1.0,1.0,1.0,-1.0,-2.0});
static Quintic FromRoots(const QVector< double > &)
Create a quintic from a set of roots.
Definition quintic.cpp:257
Warning
The vector must contain exactly 5 elements. No bounds checking is performed; passing a vector with fewer than 5 elements causes undefined behaviour.

◆ Gaussian()

double Quintic::Gaussian ( const double & c,
const double & r,
const double & x )
inlinestatic

Compute a compactly supported Gaussian-like pulse.

The function has \( C^2 \) continuity.

See also
Cubic::Gaussian()
Parameters
cCenter.
rRadius.
xValue.

◆ GaussianThick()

double Quintic::GaussianThick ( const double & c,
const double & t,
const double & r,
const double & x )
inlinestatic

Compute a compactly supported Gaussian-like pulse with a thick plateau.

See also
Cubic::GaussianThick()
Quintic::Gaussian()
Parameters
cCenter.
t,rThickness (plateau) and radius.
xValue.

◆ Hermite()

Quintic Quintic::Hermite ( const double & a,
const double & b,
const double & ta,
const double & tb,
const double & na,
const double & nb )
static

Creates an Hermite quintic polynomial on interval [0,1].

Parameters
a,bValues at t=0 and t=1.
ta,tbDerivatives at t=0 and t=1.
na,nbSecond derivatives at t=0 and t=1.

◆ K()

double Quintic::K ( const double & a,
const double & b ) const

Compute the Lipschitz constant of the quintic.

Parameters
a,bInterval.

◆ operator()()

double Quintic::operator() ( const double & x) const
inlineconstexpr

Evaluates the quintic.

Parameters
xArgument value of the function.

◆ Range()

void Quintic::Range ( double & x,
double & y,
const double & a = 0.0,
const double & b = 1.0 ) const

Compute the range of values taken by a quintic over a given interval.

Parameters
a,bInterval.
x,yReturned range.

◆ Smooth()

double Quintic::Smooth ( const double & x)
inlinestatic

Compute the value of smooth \( C^2 \) interpolating function over unit interval.

The quintic is defined as \( x^3 (6 x^2 - 15 x + 10) \). Its first and second derivatives at 0.0 and 1.0 are 0.0.

The Lipschitz constant of the smooth quintic over [0,1] is \( \lambda = 15/8 \).

Parameters
xArgument in [0,1].
See also
Septic::Smooth(), Cubic::Smooth()

◆ SmoothCompact()

double Quintic::SmoothCompact ( const double & x,
const double & r )
inlinestatic

Compactly supported smooth interpolating function.

See also
Cubic::SmoothCompact(const double&, const double&)
Parameters
xSquared distance.
rSquared radius.

◆ SmoothStep()

double Quintic::SmoothStep ( const double & x,
const double & a,
const double & b )
inlinestatic

Compute a quintic smooth step.

The code is slightly more efficient than:

double y=Quintic::Smooth(Linear::Step(x,a,b));
static double Step(const double &, const double &, const double &)
Create a linear step.
Definition linear.h:195
Parameters
xInput value.
a,bInterval values.
See also
Cubic::SmoothStep, Septic::SmoothStep()

◆ Solve() [1/2]

int Quintic::Solve ( double * roots) const

Solve the quintic equation.

This function stores the roots in an array and returns the number of roots. The roots are not guaranteed to be sorted, and when Polynomial::Solve() uses the Sturm sequences, as the degree is larger than four, only the roots in the interval [-1e7,1e7] are found. See (double*, const double&, const double&) to select the roots in a given interval.

Calls Polynomial::Solve() when the leading coefficient is non-zero. Otherwise cascades to lower-degree solvers (Quartic, Cubic, Quadric) by dropping zero leading coefficients.

Parameters
rootsThe array of roots.
Returns
The number of roots.

◆ Solve() [2/2]

int Quintic::Solve ( double * roots,
const double & a,
const double & b ) const

Search the roots of a quintic equation over a given interval.

Parameters
rootsArray for storing the roots.
a,bInterval range.

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const Quintic & p )
friend

Overloaded output-stream operator.

Parameters
sStream.
pThe quintic.