Aim: Represents a multivariate polynomial, i.e. an element of \( K[X_0, ..., X_{n-1}] \), where K is some ring or field.
More...
|
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 |
|
|
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 > &, const MPolynomial< 1, TRing, TAlloc > &, MPolynomial< 1, TRing, TAlloc > &, MPolynomial< 1, TRing, TAlloc > &) |
|
MPolynomial | operator* (const Ring &v, const MPolynomial &p) |
|
template<int n, typename TRing, class TAlloc>
class DGtal::MPolynomial< n, TRing, TAlloc >
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.
- See also
- dgtal_multivariate_polynomial
- Template Parameters
-
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.
- Author
- Felix Fontein (
felix.nosp@m.@fon.nosp@m.tein..nosp@m.de
), University of Zurich, Switzerland
Definition at line 964 of file MPolynomial.h.
template<int n, typename TRing , class TAlloc >
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.
template<int n, typename TRing , class TAlloc >
template<typename Ring2 , typename Alloc2 >
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.
HalfEdgeDataStructure::Size Size
References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, DGtal::MPolynomial< n, TRing, TAlloc >::normalize(), and DGtal::IVector< T, TAlloc, usePointers >::size().
template<int n, typename TRing , class TAlloc >
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.
void resize(Size aSize, const T &entry=T())
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< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< N, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), DGtal::MPolynomial< n, TRing, TAlloc >::operator+=(), DGtal::MPolynomial< n, TRing, TAlloc >::operator-=(), and DGtal::MPolynomial< n, TRing, TAlloc >::operator=().
template<int n, typename TRing , class TAlloc >
Multiplies the polynomial with another polynomial.
- Parameters
-
p | any polynomial of the same type. |
- Returns
- the corresponding polynomial.
- Todo:
- Multiplication could be optimized for monovariate polynomials.
Definition at line 1467 of file MPolynomial.h.
1469 int d = p.degree() +
degree();
1473 if (!
isZero() && !p.isZero())
1474 for (
Size i = 0; i < r.myValue.size(); ++i )
1476 if (i < j + p.myValue.size())
1477 r[i] +=
myValue[j] * p[i - j];
Alloc getAllocator() const
MPolynomial(bool, Size s, const Alloc &)
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().
template<int n, typename TRing , class TAlloc >
Self-addition of this polynomial with a polynomial with one less variable.
- Parameters
-
q | any polynomial with n-1 indeterminates in the same ring. |
- Returns
- a reference to this.
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().
template<int n, typename TRing , class TAlloc >
Adds q to this polynomial.
- Parameters
-
q | any polynomial of this type. |
- Returns
- a reference to this.
Definition at line 1315 of file MPolynomial.h.
1319 for (
Size i = 0; i < q.myValue.size(); ++i )
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().
template<int n, typename TRing , class TAlloc >
Self-subtraction of this polynomial with a polynomial with one less variable.
- Parameters
-
q | any polynomial with n-1 indeterminates in the same ring. |
- Returns
- a reference to this.
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().
template<int n, typename TRing , class TAlloc >
Subtracts q from this polynomial.
- Parameters
-
q | any polynomial of this type. |
- Returns
- a reference to this.
Definition at line 1330 of file MPolynomial.h.
1334 for (
Size i = 0; i < q.myValue.size(); ++i )
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().
template<int n, typename TRing , class TAlloc >
template<typename Ring2 , typename Alloc2 >
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().
template<int n, typename TRing , class TAlloc >
void DGtal::MPolynomial< n, TRing, TAlloc >::selfDisplay |
( |
std::ostream & |
s, |
|
|
int |
N = n |
|
) |
| const |
|
inline |
template<int n, typename TRing , class TAlloc >
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< 0, n, Ring, Alloc >::computeDerivative(), DGtal::MPolynomialDerivativeComputer< N, 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< 0, TRing, TAlloc >::isZero(), DGtal::MPolynomial< n, 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< 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< 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< 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< n, TRing, TAlloc >::operator[](), DGtal::MPolynomial< n, TRing, TAlloc >::selfDisplay(), DGtal::MPolynomial< 0, TRing, TAlloc >::selfDisplay(), DGtal::MPolynomial< 0, TRing, TAlloc >::swap(), and DGtal::MPolynomial< n, TRing, TAlloc >::swap().