carl  24.04
Computer ARithmetic Library
carl::Term< Coefficient > Class Template Reference

Represents a single term, that is a numeric coefficient and a monomial. More...

#include <Term.h>

Inheritance diagram for carl::Term< Coefficient >:
Collaboration diagram for carl::Term< Coefficient >:

Public Member Functions

 Term ()=default
 Default constructor. More...
 
 Term (const Coefficient &c)
 Constructs a term of value $ c $. More...
 
 Term (Variable v)
 Constructs a term of value $ v $. More...
 
 Term (Monomial::Arg m)
 Constructs a term of value $ m $. More...
 
 Term (Monomial::Arg &&m)
 Constructs a term of value $ m $. More...
 
 Term (const Coefficient &c, Monomial::Arg m)
 Constructs a term of value $ c \cdot m $. More...
 
 Term (Coefficient &&c, Monomial::Arg &&m)
 Constructs a term of value $ c \cdot m $. More...
 
 Term (const Coefficient &c, Variable v, uint e)
 Constructs a term of value $ c \cdot v^e $. More...
 
Coefficient & coeff ()
 Get the coefficient. More...
 
const Coefficient & coeff () const
 
Monomial::Argmonomial ()
 Get the monomial. More...
 
const Monomial::Argmonomial () const
 
uint tdeg () const
 Gives the total degree, i.e. More...
 
bool is_zero () const
 Checks whether the term is zero. More...
 
bool is_one () const
 Checks whether the term equals one. More...
 
bool is_constant () const
 Checks whether the monomial is a constant. More...
 
bool integer_valued () const
 
bool is_linear () const
 Checks whether the monomial has exactly the degree one. More...
 
std::size_t num_variables () const
 
bool has (Variable v) const
 
Term drop_variable (Variable v) const
 Removes the given variable from the term. More...
 
bool has_no_other_variable (Variable v) const
 Checks if the monomial is either a constant or the only variable occuring is the variable v. More...
 
bool is_single_variable () const
 
Variable single_variable () const
 For terms with exactly one variable, get this variable. More...
 
bool is_square () const
 Checks if the term is a square. More...
 
void clear ()
 Set the term to zero with the canonical representation. More...
 
void negate ()
 Negates the term by negating the coefficient. More...
 
Term divide (const Coefficient &c) const
 
bool divide (const Coefficient &c, Term &res) const
 
bool divide (Variable v, Term &res) const
 
bool divide (const Monomial::Arg &m, Term &res) const
 
bool divide (const Term &t, Term &res) const
 
Term calcLcmAndDivideBy (const Monomial::Arg &m) const
 
bool sqrt (Term &res) const
 Calculates the square root of this term. More...
 
template<typename C = Coefficient, EnableIf< is_field_type< C >> = dummy>
bool divisible (const Term &t) const
 
template<typename C = Coefficient, DisableIf< is_field_type< C >> = dummy>
bool divisible (const Term &t) const
 
bool is_consistent () const
 

Static Public Member Functions

static bool monomialEqual (const Term &lhs, const Term &rhs)
 Checks if two terms have the same monomial. More...
 
static bool monomialEqual (const std::shared_ptr< const Term > &lhs, const std::shared_ptr< const Term > &rhs)
 
static bool monomialLess (const Term &lhs, const Term &rhs)
 
static bool monomialLess (const std::shared_ptr< const Term > &lhs, const std::shared_ptr< const Term > &rhs)
 

Private Types

using CoefficientType = Coefficient
 

Private Attributes

CoefficientType mCoeff = constant_zero<CoefficientType>::get()
 
Monomial::Arg mMonomial
 

Friends

template<typename Coeff >
std::ostream & operator<< (std::ostream &os, const Term< Coeff > &rhs)
 Streaming operator for Term. More...
 
Division operators
template<typename Coeff >
const Term< Coeffoperator/ (const Term< Coeff > &lhs, uint rhs)
 Perform a division involving a term. More...
 

Detailed Description

template<typename Coefficient>
class carl::Term< Coefficient >

Represents a single term, that is a numeric coefficient and a monomial.

Definition at line 23 of file Term.h.

Member Typedef Documentation

◆ CoefficientType

template<typename Coefficient >
using carl::Term< Coefficient >::CoefficientType = Coefficient
private

Definition at line 25 of file Term.h.

Constructor & Destructor Documentation

◆ Term() [1/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( )
default

Default constructor.

Constructs a term of value zero.

Here is the caller graph for this function:

◆ Term() [2/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( const Coefficient &  c)
explicit

Constructs a term of value $ c $.

Parameters
cCoefficient.

◆ Term() [3/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( Variable  v)
explicit

Constructs a term of value $ v $.

Parameters
vVariable.

◆ Term() [4/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( Monomial::Arg  m)
explicit

Constructs a term of value $ m $.

Parameters
mMonomial pointer.

◆ Term() [5/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( Monomial::Arg &&  m)
explicit

Constructs a term of value $ m $.

Parameters
mMonomial pointer.

◆ Term() [6/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( const Coefficient &  c,
Monomial::Arg  m 
)

Constructs a term of value $ c \cdot m $.

Parameters
cCoefficient.
mMonomial pointer.

◆ Term() [7/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( Coefficient &&  c,
Monomial::Arg &&  m 
)

Constructs a term of value $ c \cdot m $.

Parameters
cCoefficient.
mMonomial pointer.

◆ Term() [8/8]

template<typename Coefficient >
carl::Term< Coefficient >::Term ( const Coefficient &  c,
Variable  v,
uint  e 
)

Constructs a term of value $ c \cdot v^e $.

Parameters
cCoefficient.
vVariable.
eExponent.

Member Function Documentation

◆ calcLcmAndDivideBy()

template<typename Coefficient >
Term carl::Term< Coefficient >::calcLcmAndDivideBy ( const Monomial::Arg m) const
Here is the caller graph for this function:

◆ clear()

template<typename Coefficient >
void carl::Term< Coefficient >::clear ( )
inline

Set the term to zero with the canonical representation.

Definition at line 206 of file Term.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ coeff() [1/2]

template<typename Coefficient >
Coefficient& carl::Term< Coefficient >::coeff ( )
inline

Get the coefficient.

Returns
Coefficient.

Definition at line 80 of file Term.h.

Here is the caller graph for this function:

◆ coeff() [2/2]

template<typename Coefficient >
const Coefficient& carl::Term< Coefficient >::coeff ( ) const
inline

Definition at line 83 of file Term.h.

◆ divide() [1/5]

template<typename Coefficient >
Term carl::Term< Coefficient >::divide ( const Coefficient &  c) const
Parameters
ca non-zero coefficient.
Returns
Here is the caller graph for this function:

◆ divide() [2/5]

template<typename Coefficient >
bool carl::Term< Coefficient >::divide ( const Coefficient &  c,
Term< Coefficient > &  res 
) const

◆ divide() [3/5]

template<typename Coefficient >
bool carl::Term< Coefficient >::divide ( const Monomial::Arg m,
Term< Coefficient > &  res 
) const

◆ divide() [4/5]

template<typename Coefficient >
bool carl::Term< Coefficient >::divide ( const Term< Coefficient > &  t,
Term< Coefficient > &  res 
) const

◆ divide() [5/5]

template<typename Coefficient >
bool carl::Term< Coefficient >::divide ( Variable  v,
Term< Coefficient > &  res 
) const

◆ divisible() [1/2]

template<typename Coefficient >
template<typename C = Coefficient, EnableIf< is_field_type< C >> = dummy>
bool carl::Term< Coefficient >::divisible ( const Term< Coefficient > &  t) const
Here is the caller graph for this function:

◆ divisible() [2/2]

template<typename Coefficient >
template<typename C = Coefficient, DisableIf< is_field_type< C >> = dummy>
bool carl::Term< Coefficient >::divisible ( const Term< Coefficient > &  t) const

◆ drop_variable()

template<typename Coefficient >
Term carl::Term< Coefficient >::drop_variable ( Variable  v) const
inline

Removes the given variable from the term.

Definition at line 168 of file Term.h.

Here is the call graph for this function:

◆ has()

template<typename Coefficient >
bool carl::Term< Coefficient >::has ( Variable  v) const
inline
Parameters
vThe variable to check for its occurrence.
Returns
true, if the variable occurs in this term.

Definition at line 160 of file Term.h.

◆ has_no_other_variable()

template<typename Coefficient >
bool carl::Term< Coefficient >::has_no_other_variable ( Variable  v) const
inline

Checks if the monomial is either a constant or the only variable occuring is the variable v.

Parameters
vThe variable which may occur.
Returns
true if no variable occurs, or just v occurs.

Definition at line 177 of file Term.h.

◆ integer_valued()

template<typename Coefficient >
bool carl::Term< Coefficient >::integer_valued ( ) const
inline
Returns
true, if the image of this term is integer-valued.

Definition at line 134 of file Term.h.

Here is the call graph for this function:

◆ is_consistent()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_consistent ( ) const

◆ is_constant()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_constant ( ) const
inline

Checks whether the monomial is a constant.

Returns

Definition at line 127 of file Term.h.

Here is the caller graph for this function:

◆ is_linear()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_linear ( ) const
inline

Checks whether the monomial has exactly the degree one.

Returns

Definition at line 143 of file Term.h.

◆ is_one()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_one ( ) const
inline

Checks whether the term equals one.

Returns

Definition at line 120 of file Term.h.

Here is the call graph for this function:

◆ is_single_variable()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_single_variable ( ) const
inline

Definition at line 182 of file Term.h.

Here is the caller graph for this function:

◆ is_square()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_square ( ) const
inline

Checks if the term is a square.

Returns
If this is square.

Definition at line 199 of file Term.h.

◆ is_zero()

template<typename Coefficient >
bool carl::Term< Coefficient >::is_zero ( ) const
inline

Checks whether the term is zero.

Returns

Definition at line 111 of file Term.h.

Here is the call graph for this function:

◆ monomial() [1/2]

template<typename Coefficient >
Monomial::Arg& carl::Term< Coefficient >::monomial ( )
inline

Get the monomial.

Returns
Monomial.

Definition at line 91 of file Term.h.

Here is the caller graph for this function:

◆ monomial() [2/2]

template<typename Coefficient >
const Monomial::Arg& carl::Term< Coefficient >::monomial ( ) const
inline

Definition at line 94 of file Term.h.

◆ monomialEqual() [1/2]

template<typename Coefficient >
static bool carl::Term< Coefficient >::monomialEqual ( const std::shared_ptr< const Term< Coefficient > > &  lhs,
const std::shared_ptr< const Term< Coefficient > > &  rhs 
)
inlinestatic

Definition at line 283 of file Term.h.

Here is the call graph for this function:

◆ monomialEqual() [2/2]

template<typename Coefficient >
static bool carl::Term< Coefficient >::monomialEqual ( const Term< Coefficient > &  lhs,
const Term< Coefficient > &  rhs 
)
inlinestatic

Checks if two terms have the same monomial.

Parameters
lhsFirst term.
rhsSecond term.
Returns
If both terms have the same monomial.

Definition at line 280 of file Term.h.

Here is the caller graph for this function:

◆ monomialLess() [1/2]

template<typename Coefficient >
static bool carl::Term< Coefficient >::monomialLess ( const std::shared_ptr< const Term< Coefficient > > &  lhs,
const std::shared_ptr< const Term< Coefficient > > &  rhs 
)
inlinestatic

Definition at line 291 of file Term.h.

Here is the call graph for this function:

◆ monomialLess() [2/2]

template<typename Coefficient >
static bool carl::Term< Coefficient >::monomialLess ( const Term< Coefficient > &  lhs,
const Term< Coefficient > &  rhs 
)
inlinestatic

Definition at line 288 of file Term.h.

Here is the caller graph for this function:

◆ negate()

template<typename Coefficient >
void carl::Term< Coefficient >::negate ( )
inline

Negates the term by negating the coefficient.

Definition at line 214 of file Term.h.

Here is the caller graph for this function:

◆ num_variables()

template<typename Coefficient >
std::size_t carl::Term< Coefficient >::num_variables ( ) const
inline
Returns

Definition at line 151 of file Term.h.

Here is the caller graph for this function:

◆ single_variable()

template<typename Coefficient >
Variable carl::Term< Coefficient >::single_variable ( ) const
inline

For terms with exactly one variable, get this variable.

Returns
The only variable occuring in the term.

Definition at line 190 of file Term.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sqrt()

template<typename Coefficient >
bool carl::Term< Coefficient >::sqrt ( Term< Coefficient > &  res) const

Calculates the square root of this term.

Returns true, iff the term is a square as checked by is_square(). In that case, res will changed to be the square root. Otherwise, res is undefined.

Parameters
resSquare root of this term.
Returns
If square root could be calculated.

◆ tdeg()

template<typename Coefficient >
uint carl::Term< Coefficient >::tdeg ( ) const
inline

Gives the total degree, i.e.

the sum of all exponents.

Returns
Total degree.

Definition at line 101 of file Term.h.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator/

template<typename Coefficient >
template<typename Coeff >
const Term<Coeff> operator/ ( const Term< Coeff > &  lhs,
uint  rhs 
)
friend

Perform a division involving a term.

Parameters
lhsLeft hand side.
rhsRight hand side.
Returns
lhs / rhs

◆ operator<<

template<typename Coefficient >
template<typename Coeff >
std::ostream& operator<< ( std::ostream &  os,
const Term< Coeff > &  rhs 
)
friend

Streaming operator for Term.

Parameters
osOutput stream.
rhsTerm.
Returns
os

Field Documentation

◆ mCoeff

template<typename Coefficient >
CoefficientType carl::Term< Coefficient >::mCoeff = constant_zero<CoefficientType>::get()
private

Definition at line 26 of file Term.h.

◆ mMonomial

template<typename Coefficient >
Monomial::Arg carl::Term< Coefficient >::mMonomial
private

Definition at line 27 of file Term.h.


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