Template Class ResultScalar

Inheritance Relationships

Base Type

Class Documentation

template<typename T>
class ResultScalar : public sequant::Result

Result for a constant or a variable value.

Template Parameters:

T – numeric type of the constant value (eg. double, complex<double>, etc.)

Public Types

using id_t = size_t

Public Functions

inline explicit ResultScalar(T v) noexcept
inline T value() const noexcept
inline virtual ResultPtr sum(Result const &other, std::array<std::any, 3> const&) const override

Sum other Result object with this object.

Note

In std::array<std::any, 3> is expected to be [l,r,res] where the elements are the annotations for left, right and result respectively.

inline virtual ResultPtr prod(Result const &other, std::array<std::any, 3> const &maybe_empty, DeNest DeNestFlag) const override

Perform product binary operation with this object and other.

Note

In std::array<std::any, 3> is expected to be [l,r,res] where the elements are the annotations for left, right and result respectively.

inline virtual ResultPtr permute(std::array<std::any, 2> const&) const override

Permute this object according to the annotations in the argument.

Note

In std::array<std::any, 2> is expected to be [pre,post] where the elements are the annotations for the eval result before permutation and after permutation respectively.

inline virtual ResultPtr broadcast(std::array<std::any, 2> const &ann, container::svector<ResultPtr> const &new_mode_ranges) const override

Expand this result over the modes it lacks.

Used to evaluate the EvalOp::Broadcast IR node. Returns a fresh result over the modes of ann[1] that is constant along every mode absent from ann[0] and equals this result along the others. ann is [operand_annot, result_annot]; the result’s modes are a superset of this result’s. new_mode_ranges holds one rank-1 result per mode of the result that this result lacks (none if it lacks none), in the result’s mode order, built by BackendArrayOps::make_zeros (and restricted to the current batch when a batch loop runs over that mode): the result’s range along that mode is that result’s range. A mode this result carries keeps this result’s range. Not a pure virtual: only tensor-backed results need it; the default throws. A ResultScalar forwards to broadcast_scalar() of new_mode_ranges' first element.

inline virtual void add_inplace(Result const &other) override

Add other Result object into this object.

inline virtual ResultPtr symmetrize() const override

Particle symmetrize the eval result.

inline virtual ResultPtr antisymmetrize(size_t) const override

Particle antisymmetrize the eval result.

inline virtual ResultPtr mult_by_phase(std::int8_t factor) const override
inline virtual ResultPtr clone() const override

An independently owned deep copy of this result.

The copy shares no mutable state with this object: add_inplace() or write_into_slice() on either one leaves the other unchanged. Needed wherever an accumulation takes ownership of a buffer it does not own – the ordered executor’s Assemble step seeds its running sum from the first batch’s partial, which may still be read again (the producing cell has life left, or is persistent across evaluations) and so must not be mutated in place.