1 #ifndef NPSTAT_POLY1D_HH_
2 #define NPSTAT_POLY1D_HH_
27 inline Poly1D() : coeffs_(1, 0.0L) {}
29 inline virtual ~
Poly1D() {}
38 Poly1D(
const double* coeffs,
unsigned degree);
39 Poly1D(
const long double* coeffs,
unsigned degree);
48 explicit Poly1D(
const std::vector<double>& c);
49 explicit Poly1D(
const std::vector<long double>& c);
58 inline Poly1D(
const long double c0) : coeffs_(1, c0) {}
64 Poly1D(
unsigned degree,
long double leadingCoeff);
73 inline void reserve(
const unsigned degree)
74 {coeffs_.reserve(degree + 1U);}
96 inline unsigned deg()
const {
return coeffs_.size() - 1U;}
99 inline long double operator[](
const unsigned degree)
const
100 {
return degree < coeffs_.size() ? coeffs_[degree] : 0.0L;}
110 unsigned nRoots(
long double a,
long double b)
const;
123 {
return coeffs_.size() == 1U && coeffs_[0] == 0.0L;}
157 inline bool operator==(
const Poly1D& r)
const
158 {
return coeffs_ == r.coeffs_;}
159 inline bool operator!=(
const Poly1D& r)
const
160 {
return coeffs_ != r.coeffs_;}
172 std::vector<long double> coeffs_;
175 template<
typename Real>
180 : poly_(poly), shift_(shift) {}
184 inline virtual Real operator()(
const Real& x)
const
185 {
return poly_(x - shift_);}
Interface definitions and concrete simple functors for a variety of functor-based calculations.
Definition: Poly1D.hh:177
unsigned nRoots(long double a, long double b) const
void truncateLeadingZeros()
static Poly1D monicDeg2(long double b, long double c)
bool isClose(const Poly1D &r, long double eps) const
virtual long double operator()(const long double &x) const
Poly1D operator/(const Poly1D &) const
Poly1D integral(long double c) const
Poly1D operator+() const
Definition: Poly1D.hh:133
long double operator[](const unsigned degree) const
Definition: Poly1D.hh:99
unsigned deg() const
Definition: Poly1D.hh:96
Poly1D(unsigned degree, long double leadingCoeff)
Poly1D(const long double c0)
Definition: Poly1D.hh:58
Poly1D operator*(const Poly1D &) const
static Poly1D monicDeg0()
Definition: Poly1D.hh:163
Poly1D operator%(const Poly1D &) const
Poly1D(const std::vector< double > &c)
bool isNull() const
Definition: Poly1D.hh:122
void setCoefficient(unsigned degree, long double value)
void reserve(const unsigned degree)
Definition: Poly1D.hh:73
static Poly1D monicDeg1(long double b)
const std::vector< long double > & allCoefficients() const
Definition: Poly1D.hh:103
Poly1D(const double *coeffs, unsigned degree)
Poly1D derivative() const
long double leadingCoefficient() const
void truncate(const unsigned maxDegree)
Definition: AbsArrayProjector.hh:14
Definition: SimpleFunctors.hh:58