Class Tensor

Nested Relationships

Nested Types

Inheritance Relationships

Base Types

Class Documentation

class Tensor : public sequant::Expr, public sequant::AbstractTensor, public sequant::Labeled

particle-symmetric Tensor, i.e. permuting

Public Functions

Tensor() = default

constructs an uninitialized Tensor

virtual ~Tensor()
template<typename IndexRange1, typename IndexRange2, typename = std::enable_if_t<(meta::is_statically_castable_v<meta::range_value_t<IndexRange1>, Index>)&&(meta::is_statically_castable_v<meta::range_value_t<IndexRange2>, Index>)>>
inline Tensor(std::wstring_view label, const bra<IndexRange1> &bra_indices, const ket<IndexRange2> &ket_indices, Symmetry s = Symmetry::nonsymm, BraKetSymmetry bks = get_default_context().braket_symmetry(), ParticleSymmetry ps = ParticleSymmetry::symm)
Parameters:
  • label – the tensor label

  • bra_indices – list of bra indices (or objects that can be converted to indices)

  • ket_indices – list of ket indices (or objects that can be converted to indices)

  • s – the symmetry of bra or ket

  • bks – the symmetry with respect to bra-ket exchange

  • ps – the symmetry under exchange of particles

inline Tensor(std::wstring_view label, bra<index_container_type> &&bra_indices, ket<index_container_type> &&ket_indices, Symmetry s = Symmetry::nonsymm, BraKetSymmetry bks = get_default_context().braket_symmetry(), ParticleSymmetry ps = ParticleSymmetry::symm)
Parameters:
  • label – the tensor label

  • bra_indices – list of bra indices (or objects that can be converted to indices)

  • ket_indices – list of ket indices (or objects that can be converted to indices)

  • s – the symmetry of bra or ket

  • bks – the symmetry with respect to bra-ket exchange

  • ps – the symmetry under exchange of particles

inline explicit operator bool() const
Returns:

true if the Tensor is initialized

inline virtual std::wstring_view label() const override
Returns:

“core” label of the tensor

inline const auto &bra() const
inline const auto &ket() const
inline auto braket() const
Returns:

joined view of the bra and ket index ranges

inline auto const_braket() const

Note

this is to work around broken lookup rules

Returns:

view of the bra+ket index ranges

inline Symmetry symmetry() const

Returns the Symmetry object describing the symmetry of the bra and ket of the Tensor, i.e. what effect swapping indices in positions i and j in either bra or ket has on the elements of the Tensor; Tensor’s are always assumed to be particle-symmetric, i.e. swapping indices in positions i and j in both bra and ket; The allowed values are Symmetry::symm, Symmetry::antisymm, and Symmetry::nonsymm

Returns:

the Symmetry object describing the symmetry of the bra and ket of the Tensor.

inline BraKetSymmetry braket_symmetry() const
Returns:

the BraKetSymmetry object describing the symmetry of the Tensor under exchange of bra and ket.

inline ParticleSymmetry particle_symmetry() const
Returns:

the ParticleSymmetry object describing the symmetry of the Tensor under exchange of particles (columns).

inline std::size_t bra_rank() const
Returns:

number of bra indices

inline std::size_t ket_rank() const
Returns:

number of ket indices

inline std::size_t rank() const
Throws:

std::logic_error – if bra and ket ranks do not match

Returns:

number of indices in bra/ket

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

the string representation of this in the LaTeX format

virtual ExprPtr canonicalize() override

Canonicalizes this and returns the biproduct of canonicalization (e.g. phase)

Returns:

the biproduct of canonicalization, or nullptr if no biproduct generated

virtual void adjoint() override

adjoint of a Tensor swaps its bra and ket

template<template<typename, typename, typename ...Args> class Map, typename ...Args>
inline bool transform_indices(const Map<Index, Index, Args...> &index_map)

Replaces indices using the index map

Parameters:

index_map – maps Index to Index

Returns:

true if one or more indices changed

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

inline void reset_tags() const
inline hash_type bra_hash_value() const