|
Theoretica
Mathematical Library
|
A polynomial of arbitrary order. More...
#include <polynomial.h>
Public Member Functions | |
| polynomial () | |
| Initialize as an empty polynomial. | |
| polynomial (Type a) | |
| Initialize as a constant. | |
| polynomial (const std::vector< Type > &c) | |
| Initialize from an std::vector. | |
| polynomial (std::initializer_list< Type > l) | |
| Initialize from an std::initializer_list. | |
| ~polynomial () | |
| Default destructor. | |
| const Type & | at (unsigned int i) const |
| Get i-th coefficient by constant reference, with bound checking. | |
| Type & | at (unsigned int i) |
| Access i-th coefficient by reference, with bound checking. | |
| const Type & | operator[] (unsigned int i) const |
| Get the n-th order coefficient by constant reference. | |
| Type & | operator[] (unsigned int i) |
| Get the n-th order coefficient by reference. | |
| template<typename EvalType = Type> | |
| EvalType | eval (EvalType x) const |
| Evaluate the polynomial using x as variable. | |
| template<typename EvalType = Type> | |
| EvalType | operator() (EvalType x) const |
| Evaluate the polynomial using x as variable. | |
| unsigned int | find_order () const |
| Find the true order of the polynomial (ignoring trailing null coefficients) | |
| void | trim () |
| Remove trailing zero coefficients. | |
| size_t | size () const |
| Get the number of coefficients. | |
| polynomial | operator+ (const polynomial &p) const |
| Sum two polynomials. | |
| polynomial | operator- (const polynomial &p) const |
| Subtract a polynomial from another. | |
| polynomial | operator* (const polynomial &p) const |
| Multiply two polynomials. | |
| polynomial | operator/ (const polynomial &d) const |
| Polynomial division. | |
| polynomial | operator* (Type a) const |
| Multiply a polynomial by a scalar. | |
| polynomial | operator/ (Type a) const |
| Divide a polynomial by a scalar. | |
| polynomial & | operator+= (const polynomial &p) |
| Sum a polynomial to this one. | |
| polynomial & | operator-= (const polynomial &p) |
| Subtract a polynomial from this one. | |
| polynomial & | operator*= (const polynomial &p) |
| Multiply two polynomials. | |
| polynomial & | operator*= (Type a) |
| Multiply a polynomial by a scalar value. | |
| polynomial & | operator/= (const polynomial &a) |
| Multiply a polynomial by a scalar value. | |
| polynomial & | operator/= (Type a) |
| Divide a polynomial by a scalar value. | |
| bool | operator== (const polynomial &other) const |
| Check whether two polynomials are equal. | |
| auto | begin () |
| Get an iterator for the first coefficient of the polynomial. | |
| auto | end () |
| Get an iterator for the one plus last coefficient of the polynomial. | |
| auto | cbegin () |
| Get a const iterator for the first coefficient of the polynomial. | |
| auto | cend () |
| Get a const iterator for the one plus last coefficient of the polynomial. | |
| vec< complex<>, 2 > | quadratic_roots () const |
| Compute the roots of a quadratic polynomial. | |
| std::string | to_string (const std::string &unknown="x", const std::string &exponentiation="^") const |
| Convert the polynomial to string representation. | |
| operator std::string () | |
| Convert the polynomial to string representation. | |
Static Public Member Functions | |
| static polynomial< Type > | from_roots (const std::vector< Type > &roots) |
| Construct a polynomial from its roots. | |
| static polynomial< Type > | monomial (Type c, unsigned int order) |
| Returns a monomial of the given degree and coefficient. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const polynomial &obj) |
| Stream the polynomial in string representation to an output stream (std::ostream) | |
A polynomial of arbitrary order.