KrisLibrary
1.0.0
|
A simple polynomial class, p(x) = sum_{i=0}^n coef[i]*x^i. More...
#include <Polynomial.h>
Public Member Functions | |
Polynomial () | |
Initializes to the 0 polynomial. | |
Polynomial (T c) | |
Initializes to a constant polynomial. | |
Polynomial (const std::vector< T > &_coef) | |
Sets the coefficient vector. | |
Polynomial (const Polynomial< T > &p) | |
Copy constructor. | |
template<class T2 > | |
Polynomial (const Polynomial< T2 > &p) | |
cast constructor | |
void | Resize (size_t s) |
size_t | Size () const |
Size is the size of the coefficient vector. Similar to Degree but disregarding leading 0 coefficients. | |
int | Degree () const |
The degree of the polynomial. Correctly handles leading 0 coefficients. | |
void | SetCoef (size_t i, T value) |
Sets coefficient i. Automatically resizes the coefficient vector. | |
T | GetCoef (size_t i) const |
Gets coefficient i. If i is out of bounds of the coefficient vector, returns 0. | |
std::ostream & | operator<< (std::ostream &out) const |
Pretty-prints this. | |
T | Evaluate (T x) const |
Evaluates the polynomial at x. | |
Polynomial< T > | Evaluate (const Polynomial< T > &x) const |
Evaluates the polynomial given another polynomial as x. | |
T | Derivative (T x) const |
Evaluates the derivative at x. | |
T | Derivative (T x, int n) const |
Evaluates the n'th derivative at x. | |
Polynomial< T > | Differentiate () const |
Returns the derivative of this polynomial. | |
Polynomial< T > | AntiDifferentiate () const |
Returns the antiderivative of this polynomial. | |
Polynomial< T > | Differentiate (int n) const |
T | operator() (T x) const |
The operator (x) is equivalent to evaluation. | |
Polynomial< T > | operator() (const Polynomial< T > &x) const |
The operator (x) is equivalent to evaluation. | |
void | operator+= (T val) |
Adds a constant offset. | |
void | operator-= (T val) |
Subtracts a constant offset. | |
void | operator*= (T b) |
Scales by a constant. | |
void | operator/= (T b) |
Divides by a constant (if b is 0, unexpected results will hold) | |
void | operator+= (const Polynomial< T > &b) |
Adds a polynomial offset. | |
void | operator-= (const Polynomial< T > &b) |
Subtracts a polynomial offset. | |
void | operator*= (const Polynomial< T > &b) |
Scales by a polynomial. | |
Public Attributes | |
std::vector< T > | coef |
A simple polynomial class, p(x) = sum_{i=0}^n coef[i]*x^i.
Polynomial< T > Spline::Polynomial< T >::Differentiate | ( | int | n | ) | const |
return the n'th derivative of this polynomial if n < 0, returns the -n'th antiderivative
References Spline::Polynomial< T >::AntiDifferentiate(), Spline::Polynomial< T >::Differentiate(), and Spline::Polynomial< T >::Size().