carl  24.04
Computer ARithmetic Library
carl::SqrtEx< Poly > Class Template Reference

#include <SqrtEx.h>

Public Types

using Rational = typename UnderlyingNumberType< Poly >::type
 

Public Member Functions

 SqrtEx ()
 Default Constructor. More...
 
 SqrtEx (Poly &&_poly)
 Constructs a square root expression from a polynomial p leading to (p + 0 * sqrt( 0 )) / 1. More...
 
 SqrtEx (const Poly &_poly)
 
 SqrtEx (Variable::Arg _var)
 
 SqrtEx (const Poly &_constantPart, const Poly &_factor, const Poly &_denominator, const Poly &_radicand)
 Constructs a square root expression from given constant part, factor, denominator and radicand. More...
 
 SqrtEx (Poly &&_constantPart, Poly &&_factor, Poly &&_denominator, Poly &&_radicand)
 
const Poly & constant_part () const
 
const Poly & factor () const
 
const Poly & denominator () const
 
const Poly & radicand () const
 
bool has_sqrt () const
 
bool is_polynomial () const
 
Poly as_polynomial () const
 
bool is_constant () const
 
Rational asConstant () const
 
bool isRational () const
 
Rational asRational () const
 
bool is_integer () const
 
bool operator== (const SqrtEx &_toCompareWith) const
 
SqrtExoperator= (const Poly &_poly)
 
SqrtEx operator+ (const SqrtEx &rhs) const
 
SqrtEx operator- (const SqrtEx &rhs) const
 
SqrtEx operator* (const SqrtEx &rhs) const
 
SqrtEx operator/ (const SqrtEx &rhs) const
 
std::string toString (bool _infix=false, bool _friendlyNames=true) const
 

Private Member Functions

void normalize ()
 Normalizes this object, that is extracts as much as possible from the radicand into the factor and cancels the enumerator and denominator afterwards. More...
 

Private Attributes

Poly m_constant_part
 The constant part c of this square root expression (c + f * sqrt(r))/d. More...
 
Poly m_factor
 The factor f of this square root expression (c + f * sqrt(r))/d. More...
 
Poly m_denominator
 The denominator d of this square root expression (c + f * sqrt(r))/d. More...
 
Poly m_radicand
 The radicand r of this square root expression (c + f * sqrt(r))/d. More...
 

Friends

template<typename P >
std::ostream & operator<< (std::ostream &_out, const SqrtEx< P > &_sqrtEx)
 Prints the given square root expression on the given stream. More...
 

Detailed Description

template<typename Poly>
class carl::SqrtEx< Poly >

Definition at line 21 of file SqrtEx.h.

Member Typedef Documentation

◆ Rational

template<typename Poly >
using carl::SqrtEx< Poly >::Rational = typename UnderlyingNumberType<Poly>::type

Definition at line 23 of file SqrtEx.h.

Constructor & Destructor Documentation

◆ SqrtEx() [1/6]

template<typename Poly >
carl::SqrtEx< Poly >::SqrtEx ( )

Default Constructor.

( constructs (0 + 0 * sqrt( 0 )) / 1 )

◆ SqrtEx() [2/6]

template<typename Poly >
carl::SqrtEx< Poly >::SqrtEx ( Poly &&  _poly)
explicit

Constructs a square root expression from a polynomial p leading to (p + 0 * sqrt( 0 )) / 1.

Parameters
_polyThe polynomial to construct a square root expression for.

◆ SqrtEx() [3/6]

template<typename Poly >
carl::SqrtEx< Poly >::SqrtEx ( const Poly &  _poly)
inlineexplicit

Definition at line 45 of file SqrtEx.h.

◆ SqrtEx() [4/6]

template<typename Poly >
carl::SqrtEx< Poly >::SqrtEx ( Variable::Arg  _var)
inlineexplicit

Definition at line 49 of file SqrtEx.h.

◆ SqrtEx() [5/6]

template<typename Poly >
carl::SqrtEx< Poly >::SqrtEx ( const Poly &  _constantPart,
const Poly &  _factor,
const Poly &  _denominator,
const Poly &  _radicand 
)
inline

Constructs a square root expression from given constant part, factor, denominator and radicand.

Parameters
_constantPartThe constant part of the square root expression to construct.
_factorThe factor of the square root expression to construct.
_denominatorThe denominator of the square root expression to construct.
_radicandThe radicand of the square root expression to construct.

Definition at line 60 of file SqrtEx.h.

◆ SqrtEx() [6/6]

template<typename Poly >
carl::SqrtEx< Poly >::SqrtEx ( Poly &&  _constantPart,
Poly &&  _factor,
Poly &&  _denominator,
Poly &&  _radicand 
)

Member Function Documentation

◆ as_polynomial()

template<typename Poly >
Poly carl::SqrtEx< Poly >::as_polynomial ( ) const
inline
Returns
The square root expression as a polynomial (note that there must be no square root nor denominator

Definition at line 119 of file SqrtEx.h.

Here is the call graph for this function:

◆ asConstant()

template<typename Poly >
Rational carl::SqrtEx< Poly >::asConstant ( ) const
inline
Returns
This sqrtEx as an integer (note, that it must actually represent an integer then).

Definition at line 138 of file SqrtEx.h.

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

◆ asRational()

template<typename Poly >
Rational carl::SqrtEx< Poly >::asRational ( ) const
inline
Returns
This sqrtEx as a rational (note, that it must actually represent a rational then).

Definition at line 156 of file SqrtEx.h.

Here is the call graph for this function:

◆ constant_part()

template<typename Poly >
const Poly& carl::SqrtEx< Poly >::constant_part ( ) const
inline
Returns
A constant reference to the constant part of this square root expression.

Definition at line 69 of file SqrtEx.h.

Here is the caller graph for this function:

◆ denominator()

template<typename Poly >
const Poly& carl::SqrtEx< Poly >::denominator ( ) const
inline
Returns
A constant reference to the denominator of this square root expression.

Definition at line 85 of file SqrtEx.h.

Here is the caller graph for this function:

◆ factor()

template<typename Poly >
const Poly& carl::SqrtEx< Poly >::factor ( ) const
inline
Returns
A constant reference to the factor of this square root expression.

Definition at line 77 of file SqrtEx.h.

Here is the caller graph for this function:

◆ has_sqrt()

template<typename Poly >
bool carl::SqrtEx< Poly >::has_sqrt ( ) const
inline
Returns
true, if the square root expression has a non trivial radicand; false, otherwise.

Definition at line 102 of file SqrtEx.h.

Here is the call graph for this function:

◆ is_constant()

template<typename Poly >
bool carl::SqrtEx< Poly >::is_constant ( ) const
inline
Returns
true, if there is no variable in this square root expression; false, otherwise.

Definition at line 130 of file SqrtEx.h.

Here is the caller graph for this function:

◆ is_integer()

template<typename Poly >
bool carl::SqrtEx< Poly >::is_integer ( ) const
inline
Returns
true, if the this square root expression corresponds to an integer value; false, otherwise.

Definition at line 178 of file SqrtEx.h.

Here is the call graph for this function:

◆ is_polynomial()

template<typename Poly >
bool carl::SqrtEx< Poly >::is_polynomial ( ) const
inline
Returns
true, if the square root expression can be expressed as a polynomial; false, otherwise.

Definition at line 111 of file SqrtEx.h.

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

◆ isRational()

template<typename Poly >
bool carl::SqrtEx< Poly >::isRational ( ) const
inline
Returns
true, if there is no variable in this square root expression; false, otherwise.

Definition at line 148 of file SqrtEx.h.

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

◆ normalize()

template<typename Poly >
void carl::SqrtEx< Poly >::normalize ( )
private

Normalizes this object, that is extracts as much as possible from the radicand into the factor and cancels the enumerator and denominator afterwards.

◆ operator*()

template<typename Poly >
SqrtEx carl::SqrtEx< Poly >::operator* ( const SqrtEx< Poly > &  rhs) const
Parameters
_factorAFirst factor.
_factorBSecond factor.
Returns
The product of the given square root expressions.

◆ operator+()

template<typename Poly >
SqrtEx carl::SqrtEx< Poly >::operator+ ( const SqrtEx< Poly > &  rhs) const
Parameters
_summandAFirst summand.
_summandBSecond summand.
Returns
The sum of the given square root expressions.

◆ operator-()

template<typename Poly >
SqrtEx carl::SqrtEx< Poly >::operator- ( const SqrtEx< Poly > &  rhs) const
Parameters
_minuendMinuend.
_subtrahendSubtrahend.
Returns
The difference of the given square root expressions.

◆ operator/()

template<typename Poly >
SqrtEx carl::SqrtEx< Poly >::operator/ ( const SqrtEx< Poly > &  rhs) const
Parameters
_dividendDividend.
_divisorDivisor.
Returns
The result of the first given square root expression divided by the second one Note that the second argument is not allowed to contain a square root.

◆ operator=()

template<typename Poly >
SqrtEx& carl::SqrtEx< Poly >::operator= ( const Poly &  _poly)
Parameters
_sqrtExA square root expression, which gets the new content of this square root expression.
Returns
A reference to this object.
Parameters
_polyA polynomial, which gets the new content of this square root expression.
Returns
A reference to this object.

◆ operator==()

template<typename Poly >
bool carl::SqrtEx< Poly >::operator== ( const SqrtEx< Poly > &  _toCompareWith) const
Parameters
_sqrtExSquare root expression to compare with.
Returns
true, if this square root expression and the given one are equal; false, otherwise.

◆ radicand()

template<typename Poly >
const Poly& carl::SqrtEx< Poly >::radicand ( ) const
inline
Returns
A constant reference to the radicand of this square root expression.

Definition at line 93 of file SqrtEx.h.

Here is the caller graph for this function:

◆ toString()

template<typename Poly >
std::string carl::SqrtEx< Poly >::toString ( bool  _infix = false,
bool  _friendlyNames = true 
) const
Parameters
_infixA string which is printed in the beginning of each row.
_friendlyNamesA flag that indicates whether to print the variables with their internal representation (false) or with their dedicated names.
Returns
The string representation of this square root expression.

Friends And Related Function Documentation

◆ operator<<

template<typename Poly >
template<typename P >
std::ostream& operator<< ( std::ostream &  _out,
const SqrtEx< P > &  _sqrtEx 
)
friend

Prints the given square root expression on the given stream.

Parameters
_outThe stream to print on.
_sqrtExThe square root expression to print.
Returns
The stream after printing the square root expression on it.

Field Documentation

◆ m_constant_part

template<typename Poly >
Poly carl::SqrtEx< Poly >::m_constant_part
private

The constant part c of this square root expression (c + f * sqrt(r))/d.

Definition at line 26 of file SqrtEx.h.

◆ m_denominator

template<typename Poly >
Poly carl::SqrtEx< Poly >::m_denominator
private

The denominator d of this square root expression (c + f * sqrt(r))/d.

Definition at line 30 of file SqrtEx.h.

◆ m_factor

template<typename Poly >
Poly carl::SqrtEx< Poly >::m_factor
private

The factor f of this square root expression (c + f * sqrt(r))/d.

Definition at line 28 of file SqrtEx.h.

◆ m_radicand

template<typename Poly >
Poly carl::SqrtEx< Poly >::m_radicand
private

The radicand r of this square root expression (c + f * sqrt(r))/d.

Definition at line 32 of file SqrtEx.h.


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