Create Leg (vector space)#
Tensors are multilinear maps from product of vector spaces. In YASTN, the ‘’legs`` of the tensor represent individual vector spaces.
The spaces of the yastn.Tensor
are characterized by a structure yastn.Leg
.
- class yastn.Leg(sym: any = <class 'yastn.sym.sym_none.sym_none'>, s: int = 1, t: tuple = (), D: tuple = (), fusion: str = 'hard', legs: tuple = (), _verified: bool = False)[source]#
Leg()
is a hashable dataclass, defining a vector space.An abelian symmetric vector space can be specified as a direct sum of plain vector spaces (sectors), each labeled by charge \(t\)
\[V = \bigoplus_t V_t\]The action of abelian symmetry on elements of such space depends only on the charge \(t\) of the element
\[g \in G:\quad U(g) V = \bigoplus_t U(g)_t V_t.\]The size of individual sectors \({\rm dim}(V_t)\) is arbitrary.
- Parameters:
sym (module | _config(NamedTuple)) – YASTN configuration
s (int) – Signature of the leg. Either 1 (ingoing) or -1 (outgoing).
t (Sequence[int] | Sequence[Sequence[int]]) – List of charge sectors.
D (Sequence[int]) – List of dimensions of corresponding charge sectors. The lengths
len(D)
andlen(t)
must be equal.legs (Sequence[yastn.Leg]) – Includes information about fused (sub-)legs.
fusion (str) – Specification of how the fusion was performed.
- __getitem__(t) int [source]#
Size of a charge sector.
- Parameters:
t (int | Sequence[int]) – selected charge sector
- history() str [source]#
Show linearized representation of Leg fusion history.
'o' marks original legs 's' is for sum, i.e. block 'p' is for product, i.e., fuse_legs(..., mode='hard') 'm' is for meta-fusion
Example
‘p(p(oo)p(oo))’ corresponds to 4 original spaces. Two pairs are fused first, then the result gets fused.
- property tD: dict[tuple, int]#
Return charge sectors t and their sizes D as a dictionary
{t: D}
.
- yastn.random_leg(config, s=1, n=None, sigma=1, D_total=8, legs=None, nonnegative=False) yastn.Leg [source]#
Create
yastn.Leg
with distributing bond dimensions to sectors randomly according to Gaussian distribution.- Parameters:
config (module | _config(NamedTuple)) – YASTN configuration
s (int) – Signature of the leg. Either 1 (ingoing) or -1 (outgoing).
n (int or tuple) – mean charge of the distribution.
sigma (number) – standard deviation of the distribution.
D_total (int) – total bond dimension of the leg, to be distributed to sectors.
nonnegative (bool) – If
True
, cut off negative charges.legs (Sequence[yastn.Leg]) – limits charges to match provided legs (e.g., in tensor with zero charge).