Symmetric Polynomials  V3.1
A C++ library for generating symmetric polynomials with relations
Polynomial< container_t > Class Template Reference

Class for polynomials in multiple variables with relations. More...

#include <Polynomials.hpp>

Inheritance diagram for Polynomial< container_t >:
[legend]
Collaboration diagram for Polynomial< container_t >:
[legend]

Public Types

typedef container_t::scl_t scl_t
 The scalar (coefficient) type eg int64_t. More...
 
typedef container_t::exp_t exp_t
 The exponent (variable) type eg StandardVariables or HalfIdempotentVariables. More...
 
typedef container_t::deg_t deg_t
 The degree type eg size_t. More...
 

Public Member Functions

 Polynomial (const deg_t *dim_var=nullptr, const std::string *name_var=nullptr)
 Constructs zero polynomial. More...
 
 Polynomial (const exp_t &exp, scl_t coeff, const deg_t *dim_var=nullptr, const std::string *name_var=nullptr)
 Constructs polynomial with a single nonzero monomial term. More...
 
 Polynomial (int num_var, scl_t coeff, const deg_t *dim_var=nullptr, const std::string *name_var=nullptr)
 Constructs constant nonzero polynomial. More...
 
size_t number_of_variables () const
 Returns the number of variables of the polynomial. More...
 
Polynomialoperator+= (const Polynomial &other)
 Addition assignment. More...
 
Polynomialoperator-= (const Polynomial &other)
 Subtraction assignment. More...
 
Polynomialoperator*= (const Polynomial &other)
 Multiplication assignment. More...
 
Polynomialoperator*= (scl_t scalar)
 Scalar multiplication assignment. More...
 
Polynomial operator+ (const Polynomial &other) const
 Addition of polynomials. More...
 
Polynomial operator- (const Polynomial &other) const
 Subtraction of polynomials. More...
 
Polynomial operator* (const Polynomial &other) const
 Multiplication of polynomials. More...
 
template<class T = int>
Polynomial operator^ (T p) const
 Raises polynomial to integer power. More...
 

Friends

template<class cont >
std::ostream & operator<< (std::ostream &, const Polynomial< cont > &)
 Befriending the print to ostream function. More...
 

Detailed Description

template<typename container_t>
class symmp::Polynomial< container_t >

Class for polynomials in multiple variables with relations.

Template Parameters
container_tThe data storage type/ monomial container to use eg DefaultContainer .
The requirements from container_t are all non-private methods and typedefs in DefaultContainer .
Attention
If exp_t does not have a std::string static name(int,int) method, then in order to print the polynomial, the names of the variables must be manually provided through a valid std::string* in the constructor

Member Typedef Documentation

◆ scl_t

typedef container_t::scl_t scl_t

The scalar (coefficient) type eg int64_t.

◆ exp_t

typedef container_t::exp_t exp_t

The exponent (variable) type eg StandardVariables or HalfIdempotentVariables.

◆ deg_t

typedef container_t::deg_t deg_t

The degree type eg size_t.

Constructor & Destructor Documentation

◆ Polynomial() [1/3]

Polynomial ( const deg_t dim_var = nullptr,
const std::string *  name_var = nullptr 
)

Constructs zero polynomial.

Parameters
dim_varPointer to the dimensions of the variables; used when exp_t does not implement method deg_t degree() const
name_varPointer to the names of the variables; used when exp_t does not implement std::string static name(int,int)

◆ Polynomial() [2/3]

Polynomial ( const exp_t exp,
scl_t  coeff,
const deg_t dim_var = nullptr,
const std::string *  name_var = nullptr 
)

Constructs polynomial with a single nonzero monomial term.

Parameters
expThe exponent of the monomial
coeffThe coefficient of the monomial
dim_varPointer to the dimensions of the variables; used when exp_t does not implement method deg_t degree() const
name_varPointer to the names of the variables; used when exp_t does not implement std::string static name(int,int)
Warning
It is the user's responsibility to make sure coeff!=0

◆ Polynomial() [3/3]

Polynomial ( int  num_var,
scl_t  coeff,
const deg_t dim_var = nullptr,
const std::string *  name_var = nullptr 
)

Constructs constant nonzero polynomial.

Parameters
num_varThe number of variables
coeffThe coefficient of the monomial
dim_varPointer to the dimensions of the variables; used when exp_t does not implement method deg_t degree() const
name_varPointer to the names of the variables; used when exp_t does not implement std::string static name(int,int)
Warning
It is the user's responsibility to make sure coeff!=0

Member Function Documentation

◆ number_of_variables()

size_t number_of_variables ( ) const

Returns the number of variables of the polynomial.

Returns
The number of variables of *this
Warning
May only be used on nonempty polynomials

◆ operator+=()

Polynomial& operator+= ( const Polynomial< container_t > &  other)

Addition assignment.

Parameters
otherThe polynomial we add to *this
Returns
Reference to *this
Note
Efficient, in place

◆ operator-=()

Polynomial& operator-= ( const Polynomial< container_t > &  other)

Subtraction assignment.

Parameters
otherThe polynomial we subtract from *this
Returns
Reference to *this
Note
Efficient, in place

◆ operator*=() [1/2]

Polynomial& operator*= ( const Polynomial< container_t > &  other)

Multiplication assignment.

Parameters
otherThe polynomial we multiply with *this
Returns
Reference to *this
Todo:
Could this be done in place?

◆ operator*=() [2/2]

Polynomial& operator*= ( scl_t  scalar)

Scalar multiplication assignment.

Parameters
scalarThe scalar we multiply with *this
Returns
Reference to *this
Note
Efficient, in place

◆ operator+()

Polynomial operator+ ( const Polynomial< container_t > &  other) const

Addition of polynomials.

Parameters
otherThe polynomial we add to *this
Returns
(*this)+other

◆ operator-()

Polynomial operator- ( const Polynomial< container_t > &  other) const

Subtraction of polynomials.

Parameters
otherThe polynomial we subtract from *this
Returns
(*this)-other

◆ operator*()

Polynomial operator* ( const Polynomial< container_t > &  other) const

Multiplication of polynomials.

Parameters
otherThe polynomial we multiply with *this
Returns
(*this)*other

◆ operator^()

Polynomial operator^ ( p) const

Raises polynomial to integer power.

Template Parameters
TAny integer type eg int, uint64_t
Parameters
pPower we raise *this to
Returns
(*this)^p
Warning
Does nothing if p<0
Attention
Raises static_assert if T is not an integer type
Todo:
Improve implementation (current is multiplication p-many times; maybe square p/2 times instead?)

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const Polynomial< cont > &   
)
friend

Befriending the print to ostream function.


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