DGtal 1.4.0
|
Aim: Represents a multivariate polynomial, i.e. an element of \( K[X_0, ..., X_{n-1}] \), where K is some ring or field. More...
#include <DGtal/math/MPolynomial.h>
Public Types | |
typedef TRing | Ring |
typedef TAlloc | Alloc |
typedef MPolynomial< n - 1, Ring, Alloc > | MPolyNM1 |
typedef IVector< MPolyNM1, typename Alloc::template rebind< MPolyNM1 >::other,(n >1) > | Storage |
typedef Storage::Size | Size |
Public Member Functions | |
void | normalize () |
MPolynomial (const Alloc &allocator=Alloc()) | |
MPolynomial (const Ring &v, const Alloc &allocator=Alloc()) | |
MPolynomial (const MPolyNM1 &pdm1, const Alloc &) | |
template<typename Ring2 , typename Alloc2 > | |
MPolynomial (const MPolynomial< n, Ring2, Alloc2 > &p, const Alloc &allocator=Alloc()) | |
template<typename Ring2 , typename Alloc2 > | |
MPolynomial & | operator= (const MPolynomial< n, Ring2, Alloc2 > &p) |
void | swap (MPolynomial &p) |
Alloc | getAllocator () const |
int | degree () const |
const MPolyNM1 & | leading () const |
bool | isZero () const |
MPolyNM1 & | operator[] (Size i) |
const MPolyNM1 & | operator[] (Size i) const |
MPolynomialEvaluator< n, Ring, Alloc, Ring > | operator() (const Ring &x) const |
template<typename Ring2 > | |
MPolynomialEvaluator< n, Ring, Alloc, Ring2 > | operator() (const Ring2 &x) const |
MPolynomial | operator* (const Ring &v) const |
MPolynomial | operator/ (const Ring &v) const |
MPolynomial & | operator*= (const MPolynomial &p) |
MPolynomial & | operator*= (const Ring &v) |
MPolynomial & | operator/= (const Ring &v) |
MPolynomial | operator- () const |
MPolynomial | operator+ (const MPolynomial &q) const |
MPolynomial | operator- (const MPolynomial &q) const |
MPolynomial & | operator+= (const MPolynomial &q) |
MPolynomial & | operator-= (const MPolynomial &q) |
MPolynomial | operator+ (const MPolyNM1 &q) const |
MPolynomial | operator- (const MPolyNM1 &q) const |
MPolynomial | operator+ (const Ring &v) const |
MPolynomial | operator- (const Ring &v) const |
MPolynomial & | operator+= (const MPolyNM1 &q) |
MPolynomial & | operator-= (const MPolyNM1 &q) |
MPolynomial & | operator+= (const Ring &v) |
MPolynomial & | operator-= (const Ring &v) |
MPolynomial | operator* (const MPolynomial &p) const |
bool | operator== (const MPolynomial &q) const |
bool | operator!= (const MPolynomial &q) const |
bool | operator== (const Ring &v) const |
bool | operator!= (const Ring &v) const |
void | selfDisplay (std::ostream &s, int N=n) const |
bool | isValid () const |
Private Member Functions | |
MPolynomial (bool, Size s, const Alloc &) | |
Private Attributes | |
Storage | myValue |
Static Private Attributes | |
static MPolyNM1 | myZeroPolynomial |
The zero polynomial of n-1 variables for a n-multivariate polynomial. | |
Friends | |
template<int NN, int nn, typename TT , typename AA > | |
class | MPolynomialDerivativeComputer |
template<int nn, typename TT , typename AA , typename SS > | |
class | MPolynomialEvaluator |
template<int nn, typename TT , typename HLHL , typename AA , typename SS > | |
class | MPolynomialEvaluatorImpl |
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 | operator* (const Ring &v, const MPolynomial &p) |
Aim: Represents a multivariate polynomial, i.e. an element of \( K[X_0, ..., X_{n-1}] \), where K is some ring or field.
Description of template class 'MPolynomial'
Monomials are products of power of variables, like xy^2z^3. Polynomials in n variables are constructed recursively with polynomials in n - 1 variables.
There is a specialization for polynomials with no indeterminates, i.e. constants.
n | the number of variables or indeterminates. |
TRing | the type chosen for the polynomial, defines also the type of the coefficents (generally int, float or double). |
TAlloc | is an allocator for TRing, for example std::allocator<TRing>; this is also the default parameter. Usually this parameter does not needs to be changed. |
This class is a backport from Spielwiese.
Definition at line 964 of file MPolynomial.h.
typedef TAlloc DGtal::MPolynomial< n, TRing, TAlloc >::Alloc |
Definition at line 985 of file MPolynomial.h.
typedef MPolynomial< n - 1, Ring, Alloc > DGtal::MPolynomial< n, TRing, TAlloc >::MPolyNM1 |
Definition at line 986 of file MPolynomial.h.
typedef TRing DGtal::MPolynomial< n, TRing, TAlloc >::Ring |
Definition at line 984 of file MPolynomial.h.
typedef Storage::Size DGtal::MPolynomial< n, TRing, TAlloc >::Size |
Definition at line 996 of file MPolynomial.h.
typedef IVector< MPolyNM1, typename Alloc::template rebind<MPolyNM1 >::other, (n>1) > DGtal::MPolynomial< n, TRing, TAlloc >::Storage |
The type for the vector storing polynomials coefficients. For 0 or 1 variables, uses a standard vector, for more variables, uses a specific vector of pointers to polynomials, with adequate allocators. This is for efficiency purposes.
Definition at line 995 of file MPolynomial.h.
|
inlineprivate |
Private constructor for initializing an array of size s.
Definition at line 1014 of file MPolynomial.h.
Referenced by DGtal::MPolynomial< 0, TRing, TAlloc >::operator*(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator+(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator-(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator-(), and DGtal::MPolynomial< 0, TRing, TAlloc >::operator/().
|
inline |
Constructs a zero polynomial
Definition at line 1045 of file MPolynomial.h.
|
inline |
Constructs a constant polynomial with constant term v.
Definition at line 1052 of file MPolynomial.h.
|
inline |
Constructs a polynomial of type MPolynomial<n, Ring> which is initialized with a polynomial of type MPolynomial<n-1, Ring>.
Definition at line 1060 of file MPolynomial.h.
|
inline |
Casts a polynomial of type MPolynomial<n, Ring2, Alloc2> to a polynomial of type MPolynomial<n, Ring, Alloc>.
Definition at line 1070 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Definition at line 1119 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
Referenced by DGtal::EhrhartPolynomial< TSpace, TInteger >::countInterior(), DGtal::MPolynomial< n, TRing, TAlloc >::operator*(), DGtal::EhrhartPolynomial< TSpace, TInteger >::remainderInterior(), and testMPolynomial().
|
inline |
Definition at line 1107 of file MPolynomial.h.
References DGtal::IVector< T, TAlloc, usePointers >::getAllocator(), and DGtal::MPolynomial< n, TRing, TAlloc >::myValue.
Referenced by DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::operator MPolyNM1(), DGtal::MPolynomial< n, TRing, TAlloc >::operator*(), and DGtal::MPolynomial< n, TRing, TAlloc >::operator-().
bool DGtal::MPolynomial< n, TRing, TAlloc >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
|
inline |
Tests whether this polynomial is the zero polynomial.
Definition at line 1137 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
Referenced by DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::MPolynomial< n, TRing, TAlloc >::operator*(), and DGtal::MPolynomial< n, TRing, TAlloc >::selfDisplay().
|
inline |
Definition at line 1129 of file MPolynomial.h.
References DGtal::IVector< T, TAlloc, usePointers >::back(), DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::myZeroPolynomial, and DGtal::IVector< T, TAlloc, usePointers >::size().
Referenced by testMPolynomial().
|
inline |
Adjusts the size of myValue that the leading term and degree can be computed trivially. This must be called only after calls to the non-const operator[], in which the degree of the polynomial has potentially been changed.
Definition at line 1025 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::isZero(), DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
Referenced by DGtal::MPolynomialDerivativeComputer< N, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), and DGtal::MPolynomial< n, TRing, TAlloc >::operator=().
|
inline |
Inequality operator.
q | any polynomial of the same type as this. |
Definition at line 1505 of file MPolynomial.h.
|
inline |
Inequality operator with a constant.
v | any value in the ring. |
Definition at line 1529 of file MPolynomial.h.
|
inline |
Evaluation in x.
x | a value in the ring. |
Definition at line 1169 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomialEvaluator.
|
inline |
Evaluation in x of type Ring2.
Ring2 | another ring (like a polynomial with less variables). |
x | a value in this ring. |
Definition at line 1183 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomialEvaluator.
|
inline |
Multiplies the polynomial with another polynomial.
p | any polynomial of the same type. |
Definition at line 1467 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::degree(), DGtal::MPolynomial< n, TRing, TAlloc >::getAllocator(), DGtal::MPolynomial< n, TRing, TAlloc >::isZero(), DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Multiply by constant.
v | any value in the ring. |
Definition at line 1196 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Self-multiplication by other polynomial.
p | any polynomial of the same type. |
Definition at line 1222 of file MPolynomial.h.
|
inline |
Self-multiplication by a constant.
v | any value in the ring. |
Definition at line 1232 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Computes the sum of this polynomial with a polynomial with one less variable.
q | any polynomial with n-1 indeterminates in the same ring. |
Definition at line 1346 of file MPolynomial.h.
|
inline |
Computes the sum of two polynomials.
q | any polynomial of this type. |
Definition at line 1283 of file MPolynomial.h.
|
inline |
Addition with a constant.
v | any value in the ring. |
Definition at line 1377 of file MPolynomial.h.
|
inline |
Self-addition of this polynomial with a polynomial with one less variable.
q | any polynomial with n-1 indeterminates in the same ring. |
Definition at line 1408 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Adds q to this polynomial.
q | any polynomial of this type. |
Definition at line 1315 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Self-addition of a constant.
v | any value in the ring. |
Definition at line 1437 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Definition at line 1270 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::getAllocator(), DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Computes the difference of this polynomial with a polynomial with one less variable.
q | any polynomial with n-1 indeterminates in the same ring. |
Definition at line 1362 of file MPolynomial.h.
|
inline |
Computes the difference of two polynomials.
q | any polynomial of this type. |
Definition at line 1299 of file MPolynomial.h.
|
inline |
Difference to a constant.
v | any value in the ring. |
Definition at line 1392 of file MPolynomial.h.
|
inline |
Self-subtraction of this polynomial with a polynomial with one less variable.
q | any polynomial with n-1 indeterminates in the same ring. |
Definition at line 1423 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Subtracts q from this polynomial.
q | any polynomial of this type. |
Definition at line 1330 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Self-subtraction of a constant.
v | any value in the ring. |
Definition at line 1451 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Divide by constant.
v | any value in the ring. |
Definition at line 1209 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Self-division by a constant.
v | any value in the ring. |
Definition at line 1245 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Copies a polynomial of type MPolynomial<n, Ring2, Alloc2> to this polynomial (of type MPolynomial<n, Ring, Alloc>).
Definition at line 1085 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Equality operator.
q | any polynomial of the same type as this. |
Definition at line 1490 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Equality operator with a constant.
v | any value in the ring. |
Definition at line 1515 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Definition at line 1147 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::IVector< T, TAlloc, usePointers >::resize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Definition at line 1157 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::myZeroPolynomial, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Prints this polynomial to the stream s. N gives the number of variables; this is needed for recursive printing.
s | the output stream where the object is written. |
N | the number of variables. |
Definition at line 1546 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::isZero(), DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().
|
inline |
Swaps two polynomials.
p | the polynomial to exchange with. |
Definition at line 1099 of file MPolynomial.h.
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::swap().
|
friend |
Forward declaration, to be able to declare this as a friend.
|
friend |
Definition at line 969 of file MPolynomial.h.
|
friend |
Definition at line 978 of file MPolynomial.h.
Referenced by DGtal::MPolynomial< n, TRing, TAlloc >::operator()(), and DGtal::MPolynomial< n, TRing, TAlloc >::operator()().
|
friend |
Definition at line 981 of file MPolynomial.h.
|
friend |
Multiplication by a constant from the left.
v | any value in the ring. |
p | any polynomial of this type. |
Definition at line 1259 of file MPolynomial.h.
|
private |
The vector storing polynomials coefficients. For 0 or 1 variables, uses a standard vector, for more variables, uses a specific vector of pointers to polynomials, with adequate allocators. This is for efficiency purposes.
Definition at line 1008 of file MPolynomial.h.
Referenced by DGtal::MPolynomialDerivativeComputer< N, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomial< n, TRing, TAlloc >::degree(), DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::evaluate(), DGtal::MPolynomial< n, TRing, TAlloc >::getAllocator(), DGtal::MPolynomial< n, TRing, TAlloc >::isZero(), DGtal::MPolynomial< 0, TRing, TAlloc >::isZero(), DGtal::MPolynomial< n, TRing, TAlloc >::leading(), DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator const Ring &(), DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::operator MPolyNM1(), DGtal::MPolynomialEvaluator< 1, TRing, TAlloc, TX >::operator X(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator!=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator()(), DGtal::MPolynomial< n, TRing, TAlloc >::operator*(), DGtal::MPolynomial< n, TRing, TAlloc >::operator*(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator*(), DGtal::MPolynomial< n, TRing, TAlloc >::operator*=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator*=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator+(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator-(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator-(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator-=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator/(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator/(), DGtal::MPolynomial< n, TRing, TAlloc >::operator/=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator/=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator=(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator==(), DGtal::MPolynomial< n, TRing, TAlloc >::operator==(), DGtal::MPolynomial< 0, TRing, TAlloc >::operator==(), DGtal::MPolynomial< n, TRing, TAlloc >::operator[](), DGtal::MPolynomial< n, TRing, TAlloc >::operator[](), DGtal::MPolynomial< n, TRing, TAlloc >::selfDisplay(), DGtal::MPolynomial< 0, TRing, TAlloc >::selfDisplay(), DGtal::MPolynomial< n, TRing, TAlloc >::swap(), and DGtal::MPolynomial< 0, TRing, TAlloc >::swap().
|
staticprivate |
The zero polynomial of n-1 variables for a n-multivariate polynomial.
Definition at line 1001 of file MPolynomial.h.
Referenced by DGtal::MPolynomial< n, TRing, TAlloc >::leading(), and DGtal::MPolynomial< n, TRing, TAlloc >::operator[]().