Class for polynomials in multiple variables with relations.
More...
#include <Polynomials.hpp>
|
template<class cont > |
std::ostream & | operator<< (std::ostream &, const Polynomial< cont > &) |
| Befriending the print to ostream function. More...
|
|
template<typename container_t>
class symmp::Polynomial< container_t >
Class for polynomials in multiple variables with relations.
- Template Parameters
-
container_t | The 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
◆ 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 |
◆ deg_t
typedef container_t::deg_t deg_t |
The degree type eg size_t
.
◆ Polynomial() [1/3]
Polynomial |
( |
const deg_t * |
dim_var = nullptr , |
|
|
const std::string * |
name_var = nullptr |
|
) |
| |
Constructs zero polynomial.
- Parameters
-
dim_var | Pointer to the dimensions of the variables; used when exp_t does not implement method deg_t degree() const |
name_var | Pointer to the names of the variables; used when exp_t does not implement std::string static name(int,int) |
◆ Polynomial() [2/3]
Constructs polynomial with a single nonzero monomial term.
- Parameters
-
exp | The exponent of the monomial |
coeff | The coefficient of the monomial |
dim_var | Pointer to the dimensions of the variables; used when exp_t does not implement method deg_t degree() const |
name_var | Pointer 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_var | The number of variables |
coeff | The coefficient of the monomial |
dim_var | Pointer to the dimensions of the variables; used when exp_t does not implement method deg_t degree() const |
name_var | Pointer 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
◆ 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+=()
Addition assignment.
- Parameters
-
other | The polynomial we add to *this
|
- Returns
- Reference to
*this
- Note
- Efficient, in place
◆ operator-=()
Subtraction assignment.
- Parameters
-
other | The polynomial we subtract from *this
|
- Returns
- Reference to
*this
- Note
- Efficient, in place
◆ operator*=() [1/2]
Multiplication assignment.
- Parameters
-
other | The polynomial we multiply with *this
|
- Returns
- Reference to
*this
- Todo:
- Could this be done in place?
◆ operator*=() [2/2]
Scalar multiplication assignment.
- Parameters
-
scalar | The scalar we multiply with *this
|
- Returns
- Reference to
*this
- Note
- Efficient, in place
◆ operator+()
Addition of polynomials.
- Parameters
-
other | The polynomial we add to *this |
- Returns
(*this)+other
◆ operator-()
Subtraction of polynomials.
- Parameters
-
other | The polynomial we subtract from *this |
- Returns
(*this)-other
◆ operator*()
Multiplication of polynomials.
- Parameters
-
other | The polynomial we multiply with *this |
- Returns
(*this)*other
◆ operator^()
Raises polynomial to integer power.
- Template Parameters
-
T | Any integer type eg int, uint64_t |
- Parameters
-
- 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?)
◆ 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: