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
- Examples
- math/polynomial-derivative.cpp, math/polynomial-read.cpp, math/polynomial2-derivative.cpp, and topology/trackImplicitPolynomialSurfaceToOFF.cpp.
Definition at line 954 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 985 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 1060 of file MPolynomial.h.
1063 {
1067 }
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 1015 of file MPolynomial.h.
1016 {
1018 while ( dp1 )
1019 {
1021 --dp1;
1022 else
1023 break;
1024 }
1027 }
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 1457 of file MPolynomial.h.
1458 {
1459 int d = p.degree() +
degree();
1460 if (d < -1)
1461 d = -1;
1463 if (!
isZero() && !p.isZero())
1464 for (
Size i = 0; i < r.myValue.size(); ++i )
1466 if (i < j + p.myValue.size())
1467 r[i] +=
myValue[j] * p[i - j];
1468 r.normalize();
1469 return r;
1470 }
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 1398 of file MPolynomial.h.
1399 {
1404 return *this;
1405 }
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 1305 of file MPolynomial.h.
1306 {
1309 for (
Size i = 0; i < q.myValue.size(); ++i )
1312 return *this;
1313 }
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 1413 of file MPolynomial.h.
1414 {
1419 return *this;
1420 }
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 1320 of file MPolynomial.h.
1321 {
1324 for (
Size i = 0; i < q.myValue.size(); ++i )
1327 return *this;
1328 }
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 1075 of file MPolynomial.h.
1077 {
1082 return *this;
1083 }
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 998 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().