Polynomial

Functions

template<class T>
Polynomial<T> operator+(const Polynomial<T> &P, const Polynomial<T> &Q)
template<class T>
Polynomial<T> operator*(const Polynomial<T> &P, const Polynomial<T> &Q)
template<class T>
Polynomial<T> operator*(const T lambda, const Polynomial<T> &P)
template<class T>
bool operator==(const Polynomial<T> &P, const Polynomial<T> &Q)
template<class T>
std::ostream &operator<<(std::ostream &os, const Polynomial<T> &P)
template<class T>
Polynomial<T> lagrangePolynomial(const std::vector<std::pair<T, T>> &points)
template<class T>
class Polynomial

Public Functions

inline Polynomial(const std::vector<T> &coefs = {})

The coefficients must be given lower degree first.

inline Polynomial(const T cst)

Constant polynomial.

inline int degree() const
inline T coef(const int i) const
template<class U>
U operator()(const U &x) const

Evalute the polynomial.

void operator+=(const Polynomial<T> &P)
void operator*=(const Polynomial<T> &P)

Private Functions

void removeLeadingZeros()

Private Members

std::vector<T> m_coefs

Friends

template<class T_>
friend Polynomial<T_> operator+(const Polynomial<T_> &P, const Polynomial<T_> &Q)
template<class T_>
friend Polynomial<T_> operator*(const Polynomial<T_> &P, const Polynomial<T_> &Q)
template<class T_>
friend Polynomial<T_> operator*(const T_ lambda, const Polynomial<T_> &P)
template<class T_>
friend bool operator==(const Polynomial<T_> &P, const Polynomial<T_> &Q)
template<class T_>
friend std::ostream &operator<<(std::ostream &os, const Polynomial<T_> &P)