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 = (), hf: tuple = None, _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) and len(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

conj() Leg[source]#

New yastn.Leg with switched signature.

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.leg_product(*legs, t_allowed=None) Leg[source]#

Output Leg being an outer product of a list of legs.

Equivalent to result of yastn.Tensor.get_legs() from tensor with fused legs (up to possibility that not all possible effective charges have to appear in fused tensor).

Parameters:
  • legs (yastn.Leg) – legs to compute outer product from.

  • t_allowed (Sequence[Sequence[int]]) – limit effective charges to the ones provided in the list.

yastn.undo_leg_product(leg) Sequence[Leg][source]#

Reverse the operation of yastn.leg_product().

Parameters:

leg (yastn.Leg) – legs to compute outer product from.

yastn.gaussian_leg(config, s=1, n=None, sigma=1, D_total=8, legs=None, nonnegative=False, method='round', spanning_vectors=None) Leg[source]#

Create yastn.Leg randomly distributing bond dimensions to sectors 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[int, …]) – 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).

  • method (str) – For ‘round’, approximate the integer sectorial bond dimensions to match gaussian distribution. For ‘rand’, distribute sectorial bond dimensions randomly from gaussian distribution. The default is ‘round’, which gives repeatable outcomes.

yastn.legs_union(*legs) Leg[source]#

Output Leg that represent space being an union of spaces of a list of legs.

It collects charges appearing in all provided legs. Their dimensions and fusion history have to match.