Helper class for differentiating and integrating polynomials.
More...
#include <polynomial.hpp>
- Author
- Joel Andersson
- Date
- 2014
Extra doc: https://github.com/casadi/casadi/wiki/L_8y
Definition at line 39 of file polynomial.hpp.
◆ Polynomial() [1/5]
casadi::Polynomial::Polynomial |
( |
double |
scalar = 1 | ) |
|
◆ Polynomial() [2/5]
casadi::Polynomial::Polynomial |
( |
double |
p0, |
|
|
double |
p1 |
|
) |
| |
◆ Polynomial() [3/5]
casadi::Polynomial::Polynomial |
( |
double |
p0, |
|
|
double |
p1, |
|
|
double |
p2 |
|
) |
| |
◆ Polynomial() [4/5]
casadi::Polynomial::Polynomial |
( |
double |
p0, |
|
|
double |
p1, |
|
|
double |
p2, |
|
|
double |
p3 |
|
) |
| |
◆ Polynomial() [5/5]
template<typename T >
casadi::Polynomial::Polynomial |
( |
const std::vector< T > & |
coeff | ) |
|
|
inline |
Definition at line 56 of file polynomial.hpp.
const std::vector< double > & coeff() const
Coefficients of the polynomial.
◆ anti_derivative()
Polynomial casadi::Polynomial::anti_derivative |
( |
| ) |
const |
◆ coeff()
const std::vector<double>& casadi::Polynomial::coeff |
( |
| ) |
const |
|
inline |
◆ degree()
casadi_int casadi::Polynomial::degree |
( |
| ) |
const |
◆ derivative()
Polynomial casadi::Polynomial::derivative |
( |
| ) |
const |
◆ disp()
void casadi::Polynomial::disp |
( |
std::ostream & |
stream, |
|
|
bool |
more = false |
|
) |
| const |
Definition at line 56 of file polynomial.cpp.
58 for (casadi_int d=0; d<
p_.size(); ++d) {
62 stream <<
" + " <<
p_[d] <<
"*x";
64 stream <<
" + " <<
p_[d] <<
"*x^" << d;
References p_.
◆ operator()()
template<typename T >
T casadi::Polynomial::operator() |
( |
const T & |
x | ) |
const |
|
inline |
◆ operator*()
Definition at line 81 of file polynomial.cpp.
82 std::vector<double> p_ret(
p_.size() + a.p_.size() - 1, 0);
83 for (casadi_int d=0; d<
p_.size(); ++d) {
84 for (casadi_int d_a=0; d_a<a.p_.size(); ++d_a) {
85 p_ret[d+d_a] +=
p_[d] * a.p_[d_a];
References p_, and Polynomial().
◆ operator*=()
◆ operator+()
◆ operator+=()
Definition at line 113 of file polynomial.cpp.
114 p_.resize(std::max(
p_.size(), b.p_.size()), 0);
115 transform(b.p_.begin(), b.p_.end(),
p_.begin(),
p_.begin(), std::plus<double>());
void trim()
Remove excess zeros.
References p_, and trim().
◆ operator-()
◆ operator-=()
Definition at line 125 of file polynomial.cpp.
126 p_.resize(std::max(
p_.size(), b.p_.size()), 0);
127 transform(
p_.begin(),
p_.begin()+b.p_.size(),
128 b.p_.begin(),
p_.begin(), std::minus<double>());
References p_, and trim().
◆ operator/()
Polynomial casadi::Polynomial::operator/ |
( |
double |
b | ) |
const |
◆ operator/=()
Polynomial & casadi::Polynomial::operator/= |
( |
double |
b | ) |
|
Definition at line 101 of file polynomial.cpp.
102 for (std::vector<double>::iterator it=
p_.begin(); it!=
p_.end(); ++it) {
References p_.
◆ scalar()
double casadi::Polynomial::scalar |
( |
| ) |
const |
Definition at line 76 of file polynomial.cpp.
77 casadi_assert_dev(
degree()==0);
casadi_int degree() const
Degree of the polynomial.
References degree(), and p_.
◆ trim()
void casadi::Polynomial::trim |
( |
| ) |
|
Definition at line 133 of file polynomial.cpp.
135 size_t new_size =
p_.size();
136 std::vector<double>::const_reverse_iterator it=
p_.rbegin();
137 while (it!=
p_.rend() && 0==*it++) new_size--;
References p_.
Referenced by operator+=(), and operator-=().
◆ type_name()
std::string casadi::Polynomial::type_name |
( |
| ) |
const |
|
inline |
◆ p_
std::vector<double> casadi::Polynomial::p_ |
|
protected |
Definition at line 120 of file polynomial.hpp.
Referenced by anti_derivative(), degree(), derivative(), disp(), operator*(), operator+=(), operator-=(), operator/=(), Polynomial(), scalar(), and trim().
The documentation for this class was generated from the following files: