PSCF v1.1
|
A Polynomial (i.e,. More...
#include <Polynomial.h>
Public Member Functions | |
Constructors, Destructors, and Assignment | |
Polynomial (int capacity=10) | |
Construct a zero polynomial. More... | |
Polynomial (T c) | |
Construct a constant polynomial. More... | |
Polynomial (Array< T > const &coeffs) | |
Construct a polynomial from array of coefficients. More... | |
Polynomial (Polynomial< T > const &other) | |
Copy constructor. More... | |
template<typename U > | |
Polynomial< T > & | operator= (Polynomial< U > const &other) |
Assignment from another polynomial. More... | |
void | setToZero () |
Assign this polynomial a value of zero. More... | |
Simple Accessors | |
int | degree () const |
Return degree of polynomial. More... | |
Arithmetic Assignment Operators | |
Polynomial< T > & | operator+= (Polynomial< T > const &a) |
Add another polynomial to this one. More... | |
Polynomial< T > & | operator+= (T a) |
Add a constant to this polynomial. More... | |
Polynomial< T > & | operator-= (Polynomial< T > const &a) |
Subtract another polynomial from this one. More... | |
Polynomial< T > & | operator-= (T a) |
Subtract a constant from this polynomial. More... | |
Polynomial< T > & | operator*= (T a) |
Multiply this polynomial by a scalar. More... | |
Polynomial< T > & | operator/= (T a) |
Divide this polynomial by a scalar. More... | |
Polynomial< T > & | operator*= (Polynomial< T > const &a) |
Multiply this polynomial by another. More... | |
Mathematical Functions (return polynomials) | |
Polynomial< T > | integrate () const |
Compute and return indefinite integral of this polynomial. More... | |
Polynomial< T > | differentiate () const |
Compute and return derivative of this polynomial. More... | |
Polynomial< T > | reflect () const |
Compute and return reflected polynomial f(-x). More... | |
Polynomial< T > | shift (T a) const |
Compute and return shifted polynomial f(x+a). More... | |
Polynomial Evaluation Functions | |
T | operator() (T x) const |
Evaluate polynomial at specific argument of type T. More... | |
double | evaluate (double x) const |
Evaluate polynomial at specific floating point argument. More... | |
static Polynomial< T > | monomial (int n) |
Return a monomial f(x) = x^{n}. More... | |
A Polynomial (i.e,.
a list of coefficents).
Definition at line 29 of file Polynomial.h.
|
inline |
Construct a zero polynomial.
Creates a zero polynomial f(x) = 0, with no stored coefficients. The capacity parameter specifies how much physical space to allocate for subsqequent growth in the array of coefficients.
capacity | initial capacity of coefficient array. |
Definition at line 263 of file Polynomial.h.
References Util::GArray< Data >::reserve().
|
inlineexplicit |
Construct a constant polynomial.
Creates a polynomial f(x) = c, with degree() = 0.
c | constant coefficient value |
Definition at line 271 of file Polynomial.h.
References Util::GArray< Data >::append(), and Util::GArray< Data >::reserve().
|
inline |
Construct a polynomial from array of coefficients.
Constructs a polynomial in which the coefficient of x^{i} is given by coeffs[i]. The logical and physical size of the coefficient array are both set to the capacity of coeffs.
coeffs | array of coefficients. |
Definition at line 282 of file Polynomial.h.
References Util::GArray< Data >::append(), Util::Array< Data >::capacity(), and Util::GArray< Data >::reserve().
|
inline |
Copy constructor.
other | Polynomial to be copied |
Definition at line 297 of file Polynomial.h.
References Util::GArray< Data >::append(), and Util::GArray< Data >::reserve().
|
inline |
Assignment from another polynomial.
other | Polynomial to assign. |
Definition at line 313 of file Polynomial.h.
References Util::GArray< Data >::append(), Util::GArray< Data >::reserve(), and Util::setToZero().
|
inline |
Assign this polynomial a value of zero.
Equivalent to GArray::clear(): Clears all coefficients, setting size = 0 and degree = -1.
Definition at line 334 of file Polynomial.h.
References Util::GArray< Data >::clear().
Referenced by Util::Polynomial< T >::differentiate(), and Util::Polynomial< T >::integrate().
|
inline |
Return degree of polynomial.
Returns size() - 1, number of coefficients - 1. By convention, a zero polynomial has degree = -1.
Definition at line 342 of file Polynomial.h.
References Util::GArray< Data >::size().
Polynomial< T > & Util::Polynomial< T >::operator+= | ( | Polynomial< T > const & | a | ) |
Add another polynomial to this one.
Upon return, *this = this + a.
a | increment (input) |
Definition at line 349 of file Polynomial.h.
References Util::GArray< Data >::append(), and UTIL_CHECK.
Polynomial< T > & Util::Polynomial< T >::operator+= | ( | T | a | ) |
Add a constant to this polynomial.
Upon return, *this = this + a.
a | increment (input) |
Definition at line 372 of file Polynomial.h.
Polynomial< T > & Util::Polynomial< T >::operator-= | ( | Polynomial< T > const & | a | ) |
Subtract another polynomial from this one.
Upon return, *this = this + a.
a | decrement (input) |
Definition at line 386 of file Polynomial.h.
References Util::GArray< Data >::append(), and UTIL_CHECK.
Polynomial< T > & Util::Polynomial< T >::operator-= | ( | T | a | ) |
Subtract a constant from this polynomial.
Upon return, *this = this + a.
a | increment (input) |
Definition at line 409 of file Polynomial.h.
|
inline |
Multiply this polynomial by a scalar.
Upon return, *this = this*a.
a | scalar factor |
Definition at line 424 of file Polynomial.h.
|
inline |
Divide this polynomial by a scalar.
Upon return, *this = this*a.
a | scalar factor (input) |
Definition at line 439 of file Polynomial.h.
Polynomial< T > & Util::Polynomial< T >::operator*= | ( | Polynomial< T > const & | a | ) |
Multiply this polynomial by another.
Upon return, *this = this*a.
a | increment (input) |
Definition at line 453 of file Polynomial.h.
References Util::GArray< Data >::append(), Util::GArray< Data >::reserve(), Util::setToZero(), Util::GArray< Data >::size(), and UTIL_ASSERT.
Polynomial< T > Util::Polynomial< T >::integrate |
Compute and return indefinite integral of this polynomial.
Returns an indefinite integral with zero constant term.
Definition at line 501 of file Polynomial.h.
References Util::DArray< Data >::allocate(), and Util::Polynomial< T >::setToZero().
Polynomial< T > Util::Polynomial< T >::differentiate |
Compute and return derivative of this polynomial.
Returns a polynomial of one smaller degree.
Definition at line 527 of file Polynomial.h.
References Util::DArray< Data >::allocate(), and Util::Polynomial< T >::setToZero().
Polynomial< T > Util::Polynomial< T >::reflect |
Compute and return reflected polynomial f(-x).
If this polynomial is f(x), this returns a polynomial g(x) = f(-x) created by the reflection operation x-> -x. This yields a polynomial in which the sign is reversed for all coefficients of odd powers of x.
Definition at line 556 of file Polynomial.h.
Polynomial< T > Util::Polynomial< T >::shift | ( | T | a | ) | const |
Compute and return shifted polynomial f(x+a).
If this polynomial is f(x), this returns a polynomial g(x) = f(x+a) created by the shift operation x-> x + a.
Definition at line 575 of file Polynomial.h.
References Util::Binomial::coeff(), and Util::Binomial::setup().
|
inline |
Evaluate polynomial at specific argument of type T.
x | value of argument |
Definition at line 601 of file Polynomial.h.
|
inline |
Evaluate polynomial at specific floating point argument.
x | value of argument x |
Definition at line 622 of file Polynomial.h.
|
static |
Return a monomial f(x) = x^{n}.
Return a monomial.
n | power of x in monomial. |
Definition at line 645 of file Polynomial.h.
References UTIL_CHECK.