MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::SparsePolynomial< C, D, M > Class Template Reference

#include <MRMesh/MRSparsePolynomial.h>

Public Types

using Term = std::pair<D, C>
 a not-zero coefficient with its degree

Public Member Functions

 SparsePolynomial ()=default
 constructs zero polynomial
 SparsePolynomial (std::vector< Term > &&)
 SparsePolynomial (C c0, D d1, C c1)
 constructs polynomial c0 + c1*x^d1
 SparsePolynomial (C c0, D d1, C c1, D d2, C c2)
 constructs polynomial c0 + c1*x^d1 + c2*x^d2
void setZeroCoeff (D d)
 sets coefficient for given degree to zero
bool empty () const
 returns true if no single polynomial coefficient is defined
bool isPositive () const
 returns true if the coefficient for the smallest not-zero degress is positive
const std::vector< Term > & get () const
 gets read-only access to all not-zero coefficients
SparsePolynomial & operator+= (const SparsePolynomial &b)
SparsePolynomial & operator-= (const SparsePolynomial &b)

Static Public Member Functions

static SparsePolynomial fromUnsortedTerms (std::vector< Term > &&terms)
 constructs polynomial from arbitrary terms with degrees not above M: sorts them by degree, sums the coefficients of equal degrees and drops zero coefficients

Friends

SparsePolynomial operator+ (SparsePolynomial a, const SparsePolynomial &b)
SparsePolynomial operator- (SparsePolynomial a, const SparsePolynomial &b)
template<typename T, typename C2, typename D2, D2 M2>
SparsePolynomialProduct< T, D2, M2 > mulAs (const SparsePolynomial< C2, D2, M2 > &a, const SparsePolynomial< C2, D2, M2 > &b)

Detailed Description

template<typename C, typename D, D M>
class MR::SparsePolynomial< C, D, M >

The class to store a polynomial with a large number of zero coefficients (only non-zeros are stored in a vector of terms sorted by ascending degree)

Template Parameters
C- type of coefficients
D- type of degrees
M- maximum degree to store in the polynomial

The documentation for this class was generated from the following file: