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>
inline explicit Constant(U &&value)
template<typename T = scalar_type>
inline auto value() const
Template Parameters:

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

Throws:
  • Exception – 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

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

the string representation of this in the LaTeX format

virtual type_id_type type_id() const override

Computes and returns the derived type identifier

Returns:

the hash value for this Expr

virtual bool is_scalar() const override

Reports if this is a pure scalar (number-like) expression.

Note

This is distinct from is_cnumber()

Warning

this returns false for all leaves by default, hence must be overridden for scalar leaf types.

Returns:

true if this is a scalar

virtual ExprPtr clone() const override
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

Constant &operator*=(const Expr &that)
Constant &operator+=(const Expr &that)
Constant &operator-=(const Expr &that)
virtual bool is_zero() const final
Returns:

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

Public Static Functions

static bool is_zero(scalar_type v)
Parameters:

v[in] a scalar

Returns:

true if this is zero