26 #ifndef CASADI_POLYNOMIAL_HPP
27 #define CASADI_POLYNOMIAL_HPP
29 # include "printable.hpp"
39 class CASADI_EXPORT
Polynomial :
public Printable<Polynomial> {
56 Polynomial(
const std::vector<T>& coeff) : p_(coeff.begin(), coeff.end()) {}
61 auto it = p_.rbegin();
63 while (it!=p_.rend()) {
71 const std::vector<double>&
coeff()
const {
return p_; }
89 std::string
type_name()
const {
return "Polynomial";}
92 void disp(std::ostream& stream,
bool more=
false)
const;
120 std::vector<double>
p_;
Helper class for differentiating and integrating polynomials.
Polynomial operator+(const Polynomial &b) const
double scalar() const
Get scalar value (error if degree()!=0)
Polynomial(double scalar=1)
Construct a constant polynomial.
void trim()
Remove excess zeros.
Polynomial & operator+=(const Polynomial &b)
Polynomial(double p0, double p1, double p2, double p3)
Construct a cubic polynomial.
Polynomial operator*(const Polynomial &b) const
Polynomial anti_derivative() const
Create a new polynomial for the anti-derivative (primitive function)
Polynomial operator-(const Polynomial &b) const
Polynomial & operator*=(const Polynomial &b)
Polynomial derivative() const
Create a new polynomial for the derivative.
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.
Polynomial operator/(double b) const
const std::vector< double > & coeff() const
Coefficients of the polynomial.
std::string type_name() const
Readable name of the class.
Polynomial(double p0, double p1)
Construct a linear polynomial.
T operator()(const T &x) const
Evaluate numerically.
Polynomial & operator-=(const Polynomial &b)
Polynomial(const std::vector< T > &coeff)
Construct from a vector of polynomial coefficients.
Polynomial & operator/=(double b)
Polynomial(double p0, double p1, double p2)
Construct a quadratic polynomial.
casadi_int degree() const
Degree of the polynomial.