36#if defined(MPolynomial_RECURSES)
37#error Recursive header files inclusion detected in MPolynomial.h
40#define MPolynomial_RECURSES
42#if !defined MPolynomial_h
49#pragma GCC diagnostic push
50#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
51#pragma clang diagnostic push
52#pragma clang diagnostic ignored "-Wdeprecated-declarations"
62#include "DGtal/base/Common.h"
68 template <
int n,
typename TRing,
69 typename TAlloc = std::allocator<TRing> >
71 template <
int N,
int n,
typename TRing,
72 typename TAlloc = std::allocator<TRing> >
74 template <
int n,
typename TRing,
75 typename TAlloc = std::allocator<TRing>,
79 template <
int n,
typename TRing,
typename TOwner,
80 typename TAlloc,
typename TX >
86 template <
typename TRing,
typename TAlloc >
100 template <
typename TRing,
typename TOwner,
101 typename TAlloc,
typename TX >
110 template <
int nn,
class TT,
class AA,
class SS>
113 template <
int nn,
class TT,
class HLHL,
class AA,
class SS>
161 inline operator X()
const
161 inline operator X()
const {
…}
192 template <
int n,
typename TRing,
typename TOwner,
193 typename TAlloc,
typename TX >
211 typename std::allocator_traits<Alloc>::template rebind_alloc<X> >
MPolyNM1;
213 template<
int nn,
class TT,
class AA,
class SS>
216 template<
int nn,
class TT,
class HLHL,
class AA,
class SS>
233 template <
typename XX,
typename Fun >
271 template <
typename XX,
typename Fun >
273 void evaluate( XX & res,
const Fun & evalfun )
const
273 void evaluate( XX & res,
const Fun & evalfun )
const {
…}
335 template <
typename XX >
344 Alloc, XX >( *
this, x );
356 template <
typename TRing,
typename TAlloc,
typename TX >
384 for (
int i = 0; i < (int)
myPoly.myValue.size(); ++i )
380 operator X()
const {
…}
411 template <
int n,
typename TRing,
typename TAlloc,
typename TX >
416 template<
int nn,
class TT,
class HLHL,
class AA,
class SS>
425 typename std::allocator_traits<Alloc>::template rebind_alloc<X> >
MPolyNM1;
441 template <
typename XX,
typename Fun >
443 void evaluate( XX & res,
const Fun & evalfun )
const
446 for (
int i = 0; i < (int)
myPoly.myValue.size(); ++i )
448 res += evalfun(
myPoly.myValue[i] ) * xx;
443 void evaluate( XX & res,
const Fun & evalfun )
const {
…}
462 for (
int i = 0; i < (int)
myPoly.myValue.size(); ++i )
473 template <
typename XX>
506 template <
typename TRing,
typename TAlloc >
553 inline operator const Ring & ()
const
553 inline operator const Ring & ()
const {
…}
731 template <
typename T,
typename TAlloc = std::allocator<T>,
732 bool usePo
inters = false>
737 typedef typename std::vector<T, Alloc>::size_type
Size;
747 :
myVec( aSize, T(), allocator )
751 :
myVec(aSize, entry, allocator)
761 myVec.resize(aSize, entry);
791 return myVec.get_allocator();
796 return myVec.get_allocator();
804 template <
typename T,
typename TAlloc>
809 typedef typename std::allocator_traits<Alloc>::pointer
TPointer;
810 typedef typename std::vector<TPointer, typename std::allocator_traits<Alloc>::template rebind_alloc<TPointer> >::size_type
Size;
814 std::vector<TPointer, typename std::allocator_traits<Alloc>::template rebind_alloc<TPointer> >
myVec;
820 for (
Size i = begin; i < end; ++i)
829 for (
Size i = begin; i < end; ++i)
894 free(aSize, oldsize);
897 create(oldsize, aSize, entry);
912 return *
myVec.back();
917 return *
myVec.back();
927 return myVec.get_allocator();
932 return myVec.get_allocator();
968 template <
int n,
typename TRing,
class TAlloc >
973 template<
int NN,
int nn,
typename TT,
typename AA>
982 template<
int nn,
typename TT,
typename AA,
typename SS>
985 template<
int nn,
typename TT,
typename HLHL,
typename AA,
typename SS>
999 typename std::allocator_traits<Alloc>::template rebind_alloc<MPolyNM1>, (n > 1) >
1074 template <
typename Ring2,
typename Alloc2 >
1088 template <
typename Ring2,
typename Alloc2 >
1114 return myValue.getAllocator();
1126 return (
int)(
myValue.size() - 1);
1186 template <
typename Ring2>
1229 return *
this = *
this * p;
1482 r[i] +=
myValue[j] * p[i - j];
1512 return !(*
this == q);
1522 if ((v == 0) && (
myValue.size() == 0))
1536 return !(*
this == v);
1561 if (nonzero > 1) s <<
"(";
1566 if (first) first =
false;
1573 if (i > 1) s <<
"^" << i;
1603 template <
int N,
typename TRing,
class TAlloc>
1617 template <
int n,
typename Ring,
typename Alloc>
1629 get(
unsigned int k,
unsigned int e )
1629 get(
unsigned int k,
unsigned int e ) {
…}
1643 template <
typename Ring,
typename Alloc>
1650 get(
unsigned int ,
unsigned int )
1650 get(
unsigned int ,
unsigned int ) {
…}
1666 template <
int n,
typename Ring,
typename Alloc>
1668 MPolynomial<n, Ring, Alloc>
1669 Xe_k(
unsigned int k,
unsigned int e )
1669 Xe_k(
unsigned int k,
unsigned int e ) {
…}
1682 template <
int n,
typename Ring>
1684 MPolynomial<n, Ring, std::allocator<Ring> >
1685 Xe_k(
unsigned int k,
unsigned int e )
1685 Xe_k(
unsigned int k,
unsigned int e ) {
…}
1698 template <
typename Ring,
typename Alloc>
1700 MPolynomial<1, Ring, Alloc>
1716 template <
typename Ring,
typename Alloc>
1718 MPolynomial<2, Ring, Alloc>
1735 template <
typename Ring,
typename Alloc>
1736 inline MPolynomial<3, Ring, Alloc>
1754 template <
typename Ring,
typename Alloc>
1756 MPolynomial<4, Ring, Alloc>
1757 mmonomial(
unsigned int e,
unsigned int f,
unsigned int g,
unsigned int h)
1757 mmonomial(
unsigned int e,
unsigned int f,
unsigned int g,
unsigned int h) {
…}
1770 template <
typename Ring>
1772 MPolynomial<1, Ring, std::allocator<Ring> >
1787 template <
typename Ring>
1789 MPolynomial<2, Ring, std::allocator<Ring> >
1805 template <
typename Ring>
1807 MPolynomial<3, Ring, std::allocator<Ring> >
1824 template <
typename Ring>
1826 MPolynomial<4, Ring, std::allocator<Ring> >
1828 (
unsigned int e,
unsigned int f,
unsigned int g,
unsigned int h)
1856 template <
int n,
typename Ring,
class Alloc>
1874 for (
int i = 1; i <= src.
degree(); ++i )
1875 dest[i - 1] = src[i] * (
Ring)i;
1901 template <
int N,
int n,
typename Ring,
typename Alloc>
1919 for (
int i = 0; i <= src.
degree(); ++i )
1929 template<
typename Ring,
class Alloc>
1933 class ERROR_N_must_be_strictly_less_than_n_in_derivative_template;
1939 ERROR_N_must_be_strictly_less_than_n_in_derivative_template();
1946 template<
int N,
typename Ring,
class Alloc>
1950 class ERROR_N_must_be_strictly_less_than_n_in_derivative_template;
1956 ERROR_N_must_be_strictly_less_than_n_in_derivative_template();
1978 template <
int N,
int n,
typename Ring,
typename Alloc>
1980 MPolynomial<n, Ring, Alloc>
2001 template<
int N,
int n,
typename Ring>
2003 MPolynomial<n, Ring, std::allocator<Ring> >
2009 ::computeDerivative( p, res );
2016 template<
typename Ring,
typename Alloc>
2033 for (
int i = q.
degree(); i >= 0; --i)
2036 for (
int j = g.
degree(); j >= 0; --j)
2037 r[i + j] -= q[i] * g[j];
2046 template <
typename Ring>
2060 template<
typename Ring,
typename Alloc>
2061 MPolynomial<1, Ring, Alloc>
2067 if (g.
isZero())
return f;
2075 while (!d2.isZero())
2089 template<
typename Ring>
2090 MPolynomial<1, Ring, std::allocator<Ring> >
2102#include "DGtal/math/MPolynomial.ih"
2104#pragma GCC diagnostic pop
2105#pragma clang diagnostic pop
2113#undef MPolynomial_RECURSES
IVector(Size aSize, const Alloc &allocator=Alloc())
Alloc getAllocator() const
IVector(Size aSize, const T &entry, const Alloc &allocator=Alloc())
IVector(const Alloc &allocator=Alloc())
void copy_from(const std::vector< TPointer, A > &source)
void resize(Size aSize, const T &entry=T())
std::vector< TPointer, typenamestd::allocator_traits< Alloc >::templaterebind_alloc< TPointer > >::size_type Size
void create(Size begin, Size end, const typename Alloc::value_type &entry)
std::allocator_traits< Alloc >::pointer TPointer
Alloc get_allocator() const
IVector(const IVector &v)
void free(Size begin, Size end)
std::vector< TPointer, typename std::allocator_traits< Alloc >::template rebind_alloc< TPointer > > myVec
std::vector< T, Alloc >::size_type Size
IVector(const Alloc &allocator=Alloc())
IVector(Size aSize, const Alloc &allocator=Alloc())
Alloc get_allocator() const
std::vector< MPolyNM1, Alloc > myVec
const T & operator[](Size i) const
IVector(Size aSize, const T &entry, const Alloc &allocator=Alloc())
Alloc getAllocator() const
void resize(Size aSize, const T &entry=T())
MPolynomial< 0, Ring, Alloc > MPoly0
static void computeDerivative(const MPoly0 &, MPoly0 &)
static void computeDerivative(const MPolyN &src, MPolyN &dest)
MPolynomial< n, Ring, Alloc > MPolyN
Type for polynomial with n variable in the ring Ring.
static void computeDerivative(const MPoly0 &, MPoly0 &)
MPolynomial< 0, Ring, Alloc > MPoly0
MPolynomial< n, Ring, Alloc > MPolyN
Type for polynomial with n variable in the ring Ring.
static void computeDerivative(const MPolyN &src, MPolyN &dest)
const MPolynomialEvaluatorImpl< n, Ring, Owner, Alloc, X > & myOwner
MPolyNM1 operator()(const MPolyN &p) const
EvalFun2(const MPolynomialEvaluatorImpl< n, Ring, Owner, Alloc, X > &owner)
const MPolynomialEvaluatorImpl< n, Ring, Owner, Alloc, X > & myOwner
XX operator()(const MPolynomial< n, Ring, Alloc > &p) const
EvalFun(const MPolynomialEvaluatorImpl< n, Ring, Owner, Alloc, X > &owner, const Fun &evalfun)
const MPolynomialEvaluatorImpl< 1, Ring, Owner, Alloc, X > & myOwner
EvalFun(const MPolynomialEvaluatorImpl< 1, Ring, Owner, Alloc, X > &owner)
const Owner & myOwner
The "owner".
friend class MPolynomialEvaluatorImpl
MPolynomialEvaluatorImpl(const Owner &owner, const X &evalpoint)
friend class MPolynomialEvaluator
const X & myEvalPoint
The evaluation point on this level.
void evaluate(XX &res, const Fun &evalfun) const
friend class MPolynomialEvaluatorImpl
MPolynomialEvaluatorImpl< n - 1, Ring, MPolynomialEvaluatorImpl< n, Ring, Owner, Alloc, X >, Alloc, XX > operator()(const XX &x) const
MPolynomial< n, Ring, Alloc > MPolyN
Type for the multivariate polynomial.
MPolynomial< n - 1, X, typename std::allocator_traits< Alloc >::template rebind_alloc< X > > MPolyNM1
friend class MPolynomialEvaluator
MPolynomialEvaluatorImpl(const Owner &owner, const X &evalpoint)
MPolynomial< 1, Ring, Alloc > MPoly1
const X & myEvalPoint
The evaluation point.
const MPoly1 & myPoly
The polynomial in question.
MPolynomialEvaluator(const MPoly1 &poly, const X &evalpoint)
friend class MPolynomialEvaluatorImpl
MPolynomial< n, Ring, Alloc > MPolyN
const X & myEvalPoint
the evaluation point
MPolynomial< n - 1, X, typename std::allocator_traits< Alloc >::template rebind_alloc< X > > MPolyNM1
MPolynomialEvaluator(const MPolyN &poly, const X &evalpoint)
MPolynomialEvaluatorImpl< n - 1, Ring, MPolynomialEvaluator< n, Ring, Alloc, X >, Alloc, XX > operator()(const XX &x) const
void evaluate(XX &res, const Fun &evalfun) const
const MPolyN & myPoly
The polynomial in question.
MPolynomial(const Alloc &allocator)
MPolynomial(const Ring &v=0, const Alloc &allocator=Alloc())
void selfDisplay(std::ostream &s, int) const
Alloc getAllocator() const
void swap(MPolynomial &p)
Aim: Represents a multivariate polynomial, i.e. an element of , where K is some ring or field.
MPolynomial(const Ring &v, const Alloc &allocator=Alloc())
bool operator==(const MPolynomial &q) const
friend class MPolynomialEvaluatorImpl
static MPolyNM1 myZeroPolynomial
MPolynomialEvaluator< n, Ring, Alloc, Ring > operator()(const Ring &x) const
friend class MPolynomialDerivativeComputer
friend void euclidDiv(const MPolynomial< 1, TRing, TAlloc > &, const MPolynomial< 1, TRing, TAlloc > &, MPolynomial< 1, TRing, TAlloc > &, MPolynomial< 1, TRing, TAlloc > &)
void selfDisplay(std::ostream &s, int N=n) const
MPolynomial(const Alloc &allocator=Alloc())
MPolynomial & operator-=(const MPolynomial &q)
MPolynomial operator/(const Ring &v) const
MPolynomial & operator/=(const Ring &v)
MPolynomial< n - 1, Ring, Alloc > MPolyNM1
MPolynomial operator-() const
MPolynomial & operator+=(const MPolynomial &q)
MPolynomial(const MPolyNM1 &pdm1, const Alloc &)
IVector< MPolyNM1, typename std::allocator_traits< Alloc >::template rebind_alloc< MPolyNM1 >,(n > 1) > Storage
MPolyNM1 & operator[](Size i)
MPolynomial & operator*=(const MPolynomial &p)
Alloc getAllocator() const
MPolynomial operator*(const Ring &v) const
bool operator!=(const MPolynomial &q) const
void swap(MPolynomial &p)
friend class MPolynomialEvaluator
const MPolyNM1 & leading() const
MPolynomial(bool, Size s, const Alloc &)
MPolynomial(const MPolynomial< n, Ring2, Alloc2 > &p, const Alloc &allocator=Alloc())
MPolynomial & operator=(const MPolynomial< n, Ring2, Alloc2 > &p)
MPolynomial operator+(const MPolynomial &q) const
MPolynomial< 0, Ring, Alloc > get(unsigned int, unsigned int)
MPolynomial< n, Ring, Alloc > get(unsigned int k, unsigned int e)
DGtal is the top-level namespace which contains all DGtal functions and types.
void euclidDiv(const MPolynomial< 1, TRing, TAlloc > &f, const MPolynomial< 1, TRing, TAlloc > &g, MPolynomial< 1, TRing, TAlloc > &q, MPolynomial< 1, TRing, TAlloc > &r)
MPolynomial< 1, Ring, Alloc > mmonomial(unsigned int e)
MPolynomial< n, Ring, Alloc > Xe_k(unsigned int k, unsigned int e)
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
MPolynomial< 1, Ring, Alloc > gcd(const MPolynomial< 1, Ring, Alloc > &f, const MPolynomial< 1, Ring, Alloc > &g)
MPolynomial< n, Ring, Alloc > derivative(const MPolynomial< n, Ring, Alloc > &p)
RealPointT::Coordinate Ring