Class Constant

Inheritance Relationships

Base Type

Class Documentation

class Constant : public sequant::Expr

a constant number

This is represented as a “compile-time” complex rational number

Public Types

using scalar_type = Complex<sequant::rational>

Public Functions

Constant() = delete
virtual ~Constant() = default
Constant(const Constant&) = default
Constant(Constant&&) = default
Constant &operator=(const Constant&) = default
Constant &operator=(Constant&&) = default
template<typename U, typename = std::enable_if_t<!is_constant_v<U>>>
inline explicit Constant(U &&value)
template<typename T = decltype(value_)>
inline auto value() const
Template Parameters:

T – the result type; default to the type of value_

Throws:
  • std::invalid_argument – if conversion to T is not possible

  • boost::numeric::positive_overflow – or boost::numeric::negative_overflow if cast fails

Returns:

the value cast to ResultType

inline virtual std::wstring to_latex() const override
Returns:

the string representation of this in the LaTeX format

inline virtual std::wstring to_wolfram() const override
Returns:

the string representation of this in the Wolfram Language format

inline virtual type_id_type type_id() const override

Computes and returns the derived type identifier

Note

this function must be overridden in the derived class

Returns:

the hash value for this Expr

inline virtual ExprPtr clone() const override

Note

- must be overridden in the derived class.

  • the default implementation throws an exception

Returns:

a clone of this object, i.e. an object that is equal to this

virtual void adjoint() override

adjoint of a Constant is its complex conjugate

inline virtual Expr &operator*=(const Expr &that) override

in-place multiply *this by that

Throws:

std::logic_error – if not implemented for this class, or cannot be implemented for the particular that

Returns:

reference to *this

inline virtual Expr &operator+=(const Expr &that) override

in-place add that to *this

Throws:

std::logic_error – if not implemented for this class, or cannot be implemented for the particular that

Returns:

reference to *this

inline virtual Expr &operator-=(const Expr &that) override

in-place subtract that from *this

Throws:

std::logic_error – if not implemented for this class, or cannot be implemented for the particular that

Returns:

reference to *this

inline bool is_zero() const
Returns:

Constant::is_zero(this->value())

Public Static Functions

static inline bool is_zero(scalar_type v)
Parameters:

v[in] a scalar

Returns:

true if this is a soft zero, i.e. its magnitude is less than std::sqrt(std::numeric_limits<float>::epsilon())