Assignments
Assignments
Util::Polynomial< 1, Degree > Class Template Reference

#include <polynomial.h>

Inheritance diagram for Util::Polynomial< 1, Degree >:
Util::VectorSpace< Polynomial< 1, Degree > >

Public Member Functions

 Polynomial (void)
 
 Polynomial (double c)
 
template<typename ... Doubles>
 Polynomial (Doubles ... coefficients)
 
template<unsigned int _Degree>
 Polynomial (const Polynomial< 1, _Degree > &p)
 
template<unsigned int _Degree>
Polynomialoperator= (const Polynomial< 1, _Degree > &p)
 
const double & coefficient (unsigned int d) const
 
double & coefficient (unsigned int d)
 
double operator() (double x) const
 
Polynomial< 1, Degree-1 > d (unsigned int d=0) const
 
Polynomial operator() (const Ray< 1 > &ray) const
 
unsigned int roots (double *r) const
 
Polynomial operator* (double s) const
 
Polynomial operator+ (const Polynomial &p) const
 
template<unsigned int _Degree>
Polynomial< 1, Degree > & operator= (const Polynomial< 1, _Degree > &p)
 
template<unsigned int Degree>
Polynomial< 1, Degree > operator+ (const Polynomial< 1, Degree > &p) const
 

Private Member Functions

const double & _coefficient (const unsigned int indices[], unsigned int maxDegree) const
 
double & _coefficient (const unsigned int indices[], unsigned int maxDegree)
 
double _evaluate (const double coordinates[], unsigned int maxDegree) const
 
Polynomial _evaluate (const Ray< 1 > &ray, unsigned int maxDegree) const
 
bool _isZero (unsigned int maxDegree) const
 
bool _isConstant (unsigned int maxDegree) const
 

Private Attributes

double _coefficients [Degree+1]
 

Detailed Description

template<unsigned int Degree>
class Util::Polynomial< 1, Degree >

A specialized instance of the Polynomial class in one variable

Constructor & Destructor Documentation

◆ Polynomial() [1/4]

template<unsigned int Degree>
Util::Polynomial< 1, Degree >::Polynomial ( void  )

The default constructor initializes the coefficients to zero.

◆ Polynomial() [2/4]

template<unsigned int Degree>
Util::Polynomial< 1, Degree >::Polynomial ( double  c)

This constructor creates a constant polynomial

◆ Polynomial() [3/4]

template<unsigned int Degree>
template<typename ... Doubles>
Util::Polynomial< 1, Degree >::Polynomial ( Doubles ...  coefficients)

This constructor initializes the coefficients (starting with lower degrees). If higher degree coefficients are not provided, they are assumed to be zero.

◆ Polynomial() [4/4]

template<unsigned int Degree>
template<unsigned int _Degree>
Util::Polynomial< 1, Degree >::Polynomial ( const Polynomial< 1, _Degree > &  p)

The constructor copies over as much of the polynomial as will fit.

Member Function Documentation

◆ _coefficient() [1/2]

template<unsigned int Degree>
double & Util::Polynomial< 1, Degree >::_coefficient ( const unsigned int  indices[],
unsigned int  maxDegree 
)
private

This method returns the specified coefficient of the polynomial.

◆ _coefficient() [2/2]

template<unsigned int Degree>
const double & Util::Polynomial< 1, Degree >::_coefficient ( const unsigned int  indices[],
unsigned int  maxDegree 
) const
private

This method returns the specified coefficient of the polynomial.

◆ _evaluate() [1/2]

template<unsigned int Degree>
double Util::Polynomial< 1, Degree >::_evaluate ( const double  coordinates[],
unsigned int  maxDegree 
) const
private

This method evaluates the polynomial at the specified set of coordinates.

◆ _evaluate() [2/2]

template<unsigned int Degree>
Polynomial< 1, Degree > Util::Polynomial< 1, Degree >::_evaluate ( const Ray< 1 > &  ray,
unsigned int  maxDegree 
) const
private

This method evaluates a Dim-dimensional polynomial along a Dim-dimensional Ray, and returns the associated 1-dimensional polynomial.

◆ _isConstant()

template<unsigned int Degree>
bool Util::Polynomial< 1, Degree >::_isConstant ( unsigned int  maxDegree) const
private

This method returns true if the polynomial is a constant.

◆ _isZero()

template<unsigned int Degree>
bool Util::Polynomial< 1, Degree >::_isZero ( unsigned int  maxDegree) const
private

This method returns true if the polynomial is zero.

◆ coefficient() [1/2]

template<unsigned int Degree>
double & Util::Polynomial< 1, Degree >::coefficient ( unsigned int  d)

This method returns the d-th coefficient.

◆ coefficient() [2/2]

template<unsigned int Degree>
const double & Util::Polynomial< 1, Degree >::coefficient ( unsigned int  d) const

This method returns the d-th coefficient.

◆ d()

template<unsigned int Degree>
Polynomial< 1, Degree-1 > Util::Polynomial< 1, Degree >::d ( unsigned int  d = 0) const

This method returns the derivative of the polynomial.

◆ operator()() [1/2]

template<unsigned int Degree>
Polynomial< 1, Degree > Util::Polynomial< 1, Degree >::operator() ( const Ray< 1 > &  ray) const

This method returns the 1D polynomial obtained by evaluating the polynomial along the 1D ray.

◆ operator()() [2/2]

template<unsigned int Degree>
double Util::Polynomial< 1, Degree >::operator() ( double  x) const

This method evaluates the polynomial at a given value.

◆ operator*()

template<unsigned int Degree>
Polynomial< 1, Degree > Util::Polynomial< 1, Degree >::operator* ( double  s) const

This method returns the scalar multiple of the polynomial

◆ operator+() [1/2]

template<unsigned int Degree>
Polynomial Util::Polynomial< 1, Degree >::operator+ ( const Polynomial< 1, Degree > &  p) const

This method returns the sum of two polynomials

◆ operator+() [2/2]

template<unsigned int Degree>
template<unsigned int Degree>
Polynomial< 1, Degree > Util::Polynomial< 1, Degree >::operator+ ( const Polynomial< 1, Degree > &  p) const

◆ operator=() [1/2]

template<unsigned int Degree>
template<unsigned int _Degree>
Polynomial & Util::Polynomial< 1, Degree >::operator= ( const Polynomial< 1, _Degree > &  p)

The equality operator copies over as much of the polynomial as will fit.

◆ operator=() [2/2]

template<unsigned int Degree>
template<unsigned int _Degree>
Polynomial< 1, Degree > & Util::Polynomial< 1, Degree >::operator= ( const Polynomial< 1, _Degree > &  p)

◆ roots()

template<unsigned int Degree>
unsigned int Util::Polynomial< 1, Degree >::roots ( double *  r) const

Sets the roots of the polynomial and returns the number of roots set. The method is only specialized for degrees 1, 2, 3, and 4.

Member Data Documentation

◆ _coefficients

template<unsigned int Degree>
double Util::Polynomial< 1, Degree >::_coefficients[Degree+1]
private

The coefficients of the polynomial.


The documentation for this class was generated from the following files: