Class Power¶
Defined in File power.hpp
Inheritance Relationships¶
Base Type¶
public sequant::Expr(Class Expr)
Class Documentation¶
-
class Power : public sequant::Expr¶
Represents base^exponent where base is a scalar (Constant or Variable) and exponent is a rational number.
Public Functions
-
Power() = delete¶
-
virtual ~Power() = default¶
-
Power(ExprPtr base, exponent_type exponent)¶
-
template<typename L>
inline Power(L &&label, exponent_type exponent)¶
-
template<typename V>
inline Power(V &&value, exponent_type exponent)¶
-
const exponent_type &exponent() const¶
- Returns:
the rational exponent
-
bool conjugated() const¶
Note
Conjugation is tracked as a flag rather than pushed into the base because, for a fixed branch,
conj(base^exponent)andconj(base)^exponentdiffer on the branch cut. As sets of branches they coincide, and SeQuant treats a Power as a branch chosen consistently, so the two are identified by Power::operator*= and by simplify(); evaluation with the principal branch agrees with this except for bases on the negative real axis.
-
void conjugate()¶
toggles the conjugation flag
-
virtual bool is_zero() const override¶
Note
Construction rejects all undefined 0^n cases; 0^0 is legal and treated as 1.
- Returns:
true if the base is zero and the exponent is positive
-
virtual std::wstring to_latex() const override¶
- Returns:
the string representation of
thisin the LaTeX format
-
virtual type_id_type type_id() const override¶
Computes and returns the derived type identifier
See also
- 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
-
Power &operator*=(const Expr &that)¶
Combines exponents when effective bases match:
b^e1 *= b^e2→b^(e1+e2)when this andthatshare the same Power-level conjugation flag.b^e *= B→b^(e+1)for a bare scalarBequal to this Power’s effective base. For a Variable base the labels must match and the effective conjugation parities align. For a Constant base only the fully unconjugated case combines.
- Throws:
Exception – if
thatis not combinable.
Public Static Functions
-
static void flatten(ExprPtr &expr)¶
Attempts to flatten a Power, mutating
exprin place. Folds whenexprholds a Power and any of:the exponent is 1 (then
b^1 = band conjugate if needed);the exponent is 0 (then
b^0 = 1for any base);the base is the
Constant1 (then1^k = 1for any rationalk);the base is a Constant and the exponent is an integer, unless the exponent times the bit width of the base, i.e. of the larger of its common denominator and
|Re numerator| + |Im numerator|over that denominator, which bounds the width of the value from above, exceeds default_max_folded_bits;the base is the
Constant0 (then0^k = 0for thek > 0the constructor admits);the base is a positive real rational and the value is rational, i.e. its simplest_radical_form() has no root (e.g.
4^{1/2} -> 2,(1/8)^{1/3} -> 1/2,(9/16)^{3/2} -> 27/64). On success,expris rebound to the folded expression; otherwise it is left unchanged.
-
Power() = delete¶