|
DGtal 2.0.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 std::allocator_traits< Alloc >::template rebind_alloc< MPolyNM1 >,(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 969 of file MPolynomial.h.
| typedef TAlloc DGtal::MPolynomial< n, TRing, TAlloc >::Alloc |
Definition at line 990 of file MPolynomial.h.
| typedef MPolynomial< n - 1, Ring, Alloc > DGtal::MPolynomial< n, TRing, TAlloc >::MPolyNM1 |
Definition at line 991 of file MPolynomial.h.
| typedef TRing DGtal::MPolynomial< n, TRing, TAlloc >::Ring |
Definition at line 989 of file MPolynomial.h.
| typedef Storage::Size DGtal::MPolynomial< n, TRing, TAlloc >::Size |
Definition at line 1001 of file MPolynomial.h.
| typedef IVector< MPolyNM1, typename std::allocator_traits<Alloc>::template rebind_alloc<MPolyNM1>, (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 1000 of file MPolynomial.h.
|
inlineprivate |
Private constructor for initializing an array of size s.
Definition at line 1019 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 1050 of file MPolynomial.h.
|
inline |
Constructs a constant polynomial with constant term v.
Definition at line 1057 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 1065 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 1075 of file MPolynomial.h.
|
inline |
Definition at line 1124 of file MPolynomial.h.
Referenced by DGtal::MPolynomialDerivativeComputer< N, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomial< n - 1, Ring, Alloc >::euclidDiv, DGtal::MPolynomial< Space::dimension, Scalar >::operator*(), DGtal::MPolynomial< Space::dimension, Scalar >::operator=(), and testMPolynomial().
|
inline |
Definition at line 1112 of file MPolynomial.h.
Referenced by DGtal::derivative(), DGtal::MPolynomial< n - 1, Ring, Alloc >::euclidDiv, DGtal::gcd(), and DGtal::MPolynomial< Space::dimension, Scalar >::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 1142 of file MPolynomial.h.
Referenced by DGtal::gcd(), DGtal::MPolynomial< Space::dimension, Scalar >::normalize(), DGtal::MPolynomial< Space::dimension, Scalar >::operator*(), and DGtal::MPolynomial< Space::dimension, Scalar >::selfDisplay().
|
inline |
Definition at line 1134 of file MPolynomial.h.
Referenced by DGtal::MPolynomial< n - 1, Ring, Alloc >::euclidDiv, DGtal::gcd(), and 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 1030 of file MPolynomial.h.
Referenced by DGtal::MPolynomialDerivativeComputer< N, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomial< n - 1, Ring, Alloc >::euclidDiv, DGtal::Xe_kComputer< n, Ring, Alloc >::get(), DGtal::MPolynomial< Space::dimension, Scalar >::MPolynomial(), DGtal::MPolynomial< Space::dimension, Scalar >::operator*(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-=(), and DGtal::MPolynomial< Space::dimension, Scalar >::operator=().
|
inline |
Inequality operator.
| q | any polynomial of the same type as this. |
Definition at line 1510 of file MPolynomial.h.
|
inline |
Inequality operator with a constant.
| v | any value in the ring. |
Definition at line 1534 of file MPolynomial.h.
|
inline |
Evaluation in x.
| x | a value in the ring. |
Definition at line 1174 of file MPolynomial.h.
|
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 1188 of file MPolynomial.h.
|
inline |
Multiplies the polynomial with another polynomial.
| p | any polynomial of the same type. |
Definition at line 1472 of file MPolynomial.h.
|
inline |
|
inline |
Self-multiplication by other polynomial.
| p | any polynomial of the same type. |
Definition at line 1227 of file MPolynomial.h.
|
inline |
|
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 1351 of file MPolynomial.h.
|
inline |
Computes the sum of two polynomials.
| q | any polynomial of this type. |
Definition at line 1288 of file MPolynomial.h.
|
inline |
|
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 1413 of file MPolynomial.h.
|
inline |
Adds q to this polynomial.
| q | any polynomial of this type. |
Definition at line 1320 of file MPolynomial.h.
|
inline |
|
inline |
|
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 1367 of file MPolynomial.h.
|
inline |
Computes the difference of two polynomials.
| q | any polynomial of this type. |
Definition at line 1304 of file MPolynomial.h.
|
inline |
|
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 1428 of file MPolynomial.h.
|
inline |
Subtracts q from this polynomial.
| q | any polynomial of this type. |
Definition at line 1335 of file MPolynomial.h.
|
inline |
|
inline |
|
inline |
|
inline |
Copies a polynomial of type MPolynomial<n, Ring2, Alloc2> to this polynomial (of type MPolynomial<n, Ring, Alloc>).
Definition at line 1090 of file MPolynomial.h.
|
inline |
Equality operator.
| q | any polynomial of the same type as this. |
Definition at line 1495 of file MPolynomial.h.
|
inline |
Equality operator with a constant.
| v | any value in the ring. |
Definition at line 1520 of file MPolynomial.h.
|
inline |
Definition at line 1152 of file MPolynomial.h.
|
inline |
Definition at line 1162 of file MPolynomial.h.
|
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 1551 of file MPolynomial.h.
|
inline |
Swaps two polynomials.
| p | the polynomial to exchange with. |
Definition at line 1104 of file MPolynomial.h.
|
friend |
Forward declaration, to be able to declare this as a friend.
|
friend |
Definition at line 974 of file MPolynomial.h.
|
friend |
Definition at line 983 of file MPolynomial.h.
Referenced by DGtal::MPolynomial< Space::dimension, Scalar >::operator()(), and DGtal::MPolynomial< Space::dimension, Scalar >::operator()().
|
friend |
Definition at line 986 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 1264 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 1013 of file MPolynomial.h.
Referenced by DGtal::MPolynomialDerivativeComputer< N, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialEvaluator< 1, TRing, TAlloc, TX >::MPolynomial< 1, TRing, TAlloc >, DGtal::MPolynomialEvaluatorImpl< n, TRing, TOwner, TAlloc, TX >::EvalFun< XX, Fun >::operator()(), DGtal::MPolynomialEvaluatorImpl< 1, TRing, TOwner, TAlloc, TX >::EvalFun::operator()(), DGtal::MPolynomial< Space::dimension, Scalar >::operator*(), DGtal::MPolynomial< Space::dimension, Scalar >::operator*, DGtal::MPolynomial< Space::dimension, Scalar >::operator+(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+(), DGtal::MPolynomial< Space::dimension, Scalar >::operator+=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-(), DGtal::MPolynomial< Space::dimension, Scalar >::operator-=(), DGtal::MPolynomial< Space::dimension, Scalar >::operator==(), DGtal::MPolynomial< 0, TRing, TAlloc >::swap(), and DGtal::MPolynomial< Space::dimension, Scalar >::swap().
|
staticprivate |
The zero polynomial of n-1 variables for a n-multivariate polynomial.
Definition at line 1006 of file MPolynomial.h.