Class Result

Inheritance Relationships

Derived Types

Class Documentation

class Result

A type-erased class for the result of an evaluation. An object of this class can represent a tensor (eg. TA::DistArray, btas::Tensor, etc.) or a scalar (eg. double, std::complex etc.).

Subclassed by sequant::ResultScalar< T >, sequant::ResultTensorBTAS< T >, sequant::ResultTensorOfTensorTA< ArrayT, typename >, sequant::ResultTensorTA< ArrayT, typename >

Public Types

using id_t = size_t

Public Functions

virtual ~Result() noexcept = default
template<typename T>
inline bool is() const noexcept
Returns:

Returns true if the concrete type of the object is T.

template<typename T>
inline T const &as() const
Returns:

T const& where T is the concrete type of the object.

virtual ResultPtr sum(Result const&, std::array<std::any, 3> const&) const = 0

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.

virtual ResultPtr prod(Result const&, std::array<std::any, 3> const&, TA::DeNest DeNestFlag) const = 0

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.

virtual ResultPtr permute(std::array<std::any, 2> const&) const = 0

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.

virtual void add_inplace(Result const&) = 0

Add other Result object into this object.

virtual ResultPtr symmetrize() const = 0

Particle symmetrize the eval result.

virtual ResultPtr antisymmetrize(size_t bra_rank) const = 0

Particle antisymmetrize the eval result.

virtual ResultPtr biorthogonal_nns_project(size_t bra_rank) const = 0

Implements “biorthogonal cleanup” of closed-shell more compact spintraced equations produced via method of Wang and Knizia.

For 3-body residual (bra_rank=3) this implements Eq. (41) of the Wang/Knizia paper, same as the first line of Figure 1. For 4-body residual this implements the first line of Figure 2. The implementation is for arbitrary ranks.

Parameters:

bra_rank – the particle rank of the residual tensor (i.e. its order halved)

bool has_value() const noexcept
virtual ResultPtr mult_by_phase(std::int8_t) const = 0
template<typename T>
inline T &get()
Template Parameters:

T, and – return a ref.

Returns:

Cast the type-erased data to the type

template<typename T>
inline T const &get() const
Template Parameters:

T, and – return a const ref.

Returns:

Cast the type-erased data to the type

virtual std::size_t size_in_bytes() const = 0
Returns:

the size of the object in bytes

Protected Functions

template<typename T, typename = std::enable_if_t<!std::is_convertible_v<T, Result>>>
inline explicit Result(T &&arg) noexcept
virtual id_t type_id() const noexcept = 0

Protected Static Functions

template<typename T>
static inline id_t id_for_type() noexcept