The STensorProxy
class is essentially a constant reference to another, pre-existing tensor.
More...
#include <stensorproxy.h>
Public Member Functions | |
bool | autodiff_enabled () const |
Returns true if autodifferentiation is enabled, causing it to also be enabled for all downstream tensors. More... | |
SBasis | b (Index which) const |
Returns the basis of the proxied object on the which -th leg. More... | |
template<Rank r> | |
Tensor< r > const & | get () const |
Returns a constant reference to the underlying tensor of the proxied object. More... | |
STensor::AutodiffRenewReturn | get_and_renew_autodiff () |
Returns a struct AutodiffRenewReturn as if by executing. More... | |
std::tuple< Autodiff::STensorId, Autodiff::ComputeNodePtr > | get_autodiff () const |
Returns a tuple of autodifferentiation ID and node. More... | |
Vec< SBasis > | get_bases () const |
Returns a vector of the effective bases of the proxied object. More... | |
Vec< Index > | get_fermionic_order () const |
Returns the effective fermionic ordering of the proxied object. More... | |
ConstSpan< Bool > | get_parities () const |
Returns a view of the parity flips. More... | |
Conj | is_conjugated () const |
Returns Conj::y() if this STensorProxy is conjugated. More... | |
EliminateZeros | is_elimzeros () const |
Returns EliminateZeros::Yes if this STensorProxy should trigger removal of zeros in tensor-tensor products. More... | |
Autodiff::STensorId | new_autodiff_id () |
Generates a new autodiff ID for the proxy. More... | |
operator SDef () const | |
Explicit conversion operator to a scalar, throws if the proxied object has non-zero rank. More... | |
operator STensor () const | |
Implicit conversion operator to a STensor , copies the proxied object. More... | |
STensorProxy & | p_r (SBasisId const &which, std::string_view to) |
Renames the specified basis to which and also primes it. More... | |
STensorProxy & | parity (SBasisId const &which) |
Flips the parity status of the leg which . More... | |
STensorProxy & | prime (SBasisId const &which, std::int8_t value=1) |
Increases the prime-level of the specified basis. More... | |
STensorProxy & | prime_all (std::int8_t value=1) |
Increases the prime-level of all bases by one. More... | |
STensor const & | proxied_object_unsafe () const |
Returns a constant reference to the proxied object without any translation. More... | |
Rank | rank () const |
Returns the rank of the proxied object. More... | |
STensorProxy & | rename (Index which, std::string_view to) |
Renames the specified basis of the proxy. More... | |
STensorProxy & | rename (SBasisId const &which, std::string_view to_what) |
Renames the specified basis of the proxy. More... | |
void | set_autodiff_node (std::string &&opname_, Vec< Pair< Autodiff::ComputeNodePtr, Size > > &&input_nodes_, Vec< Autodiff::STensorId > &&output_ids, Autodiff::AdjointEvaluator &&func_, Vec< STensor > &&output_shapes_, Vec< AsyncCached< STensor > > &&cached_tensors_={}) |
Constructs a new ComputeNode from the supplied arguments and sets this proxy's shared pointer to point at the newly-constructed node. More... | |
STensorProxy (STensor const &proxyd, Conj cn=Conj::n(), EliminateZeros ez=EliminateZeros::No, SourceLocation loc=SourceLocation::current()) | |
Standard ctor. More... | |
STensorProxy & | unprime (SBasisId const &which, std::int8_t value=1) |
Decreases the prime-level of the specified basis. More... | |
STensorProxy & | unprime_all (std::int8_t value=1) |
Decreases the prime-level of all bases by one. More... | |
template<typename F > | |
auto | visit (F func) const |
Visitor for the proxied object. More... | |
Public Attributes | |
SourceLocation | created_at |
Source location where this proxy was created. More... | |
Private Attributes | |
Autodiff::ComputeNodePtr | ad_compute_node = {} |
If autodifferentiation is enabled: pointer to compute node associated to this proxy. More... | |
Autodiff::STensorId | ad_id = 0 |
If autodifferentiation is enabled: ID of this proxy in the AD framework. More... | |
Conj | conjugate = Conj::n() |
If Conj::y() , this STensorProxy represents the dual-space conjugate of object . More... | |
EliminateZeros | ezeros = EliminateZeros::No |
If EliminateZeros::Yes , zeros should be removed during products involving this STensorProxy . More... | |
Vec< LimVec< char, 9 > > | name_overwrites |
Vector of overwrite names for bases. More... | |
STensor const & | object |
Referenced STensor. More... | |
Vec< Bool > | parities |
Vector of parities. More... | |
Vec< std::int8_t > | prime_offsets |
Vector of prime-level offsets. More... | |
The STensorProxy
class is essentially a constant reference to another, pre-existing tensor.
However, it can handle conjugation on-the-fly without the need to necessarily make a copy of the other tensor and can then ‘forward’ the conjugation to tensor-tensor products.
The STensorProxy class is implicitly convertible to a STensor and explicitly convertible to a scalar (though the latter may throw). Behaviour is undefined if the proxy'd tensor is destroyed or mutated during the lifetime of the STensorProxy class.