diff --git a/dev/index.html b/dev/index.html index b81760b4..0029b1ed 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · TensorKit.jl

TensorKit.jl

A Julia package for large-scale tensor computations, with a hint of category theory.

Package summary

TensorKit.jl aims to be a generic package for working with tensors as they appear throughout the physical sciences. TensorKit implements a parametric type Tensor (which is actually a specific case of the type TensorMap) and defines for these types a number of vector space operations (scalar multiplication, addition, norms and inner products), index operations (permutations) and linear algebra operations (multiplication, factorizations). Finally, tensor contractions can be performed using the @tensor macro from TensorOperations.jl.

Currently, most effort is oriented towards tensors as they appear in the context of quantum many body physics and in particular the field of tensor networks. Such tensors often have large dimensions and take on a specific structure when symmetries are present. To deal with generic symmetries, we employ notations and concepts from category theory all the way down to the definition of a tensor.

At the same time, TensorKit.jl focusses on computational efficiency and performance. The underlying storage of a tensor's data can be any DenseArray. Currently, certain operations are already multithreaded, either by distributing the different blocks in case of a structured tensor (i.e. with symmetries) or by using multithreading provided by the package Strided.jl. In the future, we also plan to investigate using CuArrays as underlying storage for the tensors data, so as to leverage GPUs for the different operations defined on tensors.

Contents of the manual

Library outline

+Home · TensorKit.jl

TensorKit.jl

A Julia package for large-scale tensor computations, with a hint of category theory.

Package summary

TensorKit.jl aims to be a generic package for working with tensors as they appear throughout the physical sciences. TensorKit implements a parametric type Tensor (which is actually a specific case of the type TensorMap) and defines for these types a number of vector space operations (scalar multiplication, addition, norms and inner products), index operations (permutations) and linear algebra operations (multiplication, factorizations). Finally, tensor contractions can be performed using the @tensor macro from TensorOperations.jl.

Currently, most effort is oriented towards tensors as they appear in the context of quantum many body physics and in particular the field of tensor networks. Such tensors often have large dimensions and take on a specific structure when symmetries are present. To deal with generic symmetries, we employ notations and concepts from category theory all the way down to the definition of a tensor.

At the same time, TensorKit.jl focusses on computational efficiency and performance. The underlying storage of a tensor's data can be any DenseArray. Currently, certain operations are already multithreaded, either by distributing the different blocks in case of a structured tensor (i.e. with symmetries) or by using multithreading provided by the package Strided.jl. In the future, we also plan to investigate using CuArrays as underlying storage for the tensors data, so as to leverage GPUs for the different operations defined on tensors.

Contents of the manual

Library outline

diff --git a/dev/index/index.html b/dev/index/index.html index b3c6c62b..23113bcb 100644 --- a/dev/index/index.html +++ b/dev/index/index.html @@ -1,2 +1,2 @@ -Index · TensorKit.jl

Index

+Index · TensorKit.jl

Index

diff --git a/dev/lib/sectors/index.html b/dev/lib/sectors/index.html index 93ab51b9..a32f8d08 100644 --- a/dev/lib/sectors/index.html +++ b/dev/lib/sectors/index.html @@ -1,32 +1,32 @@ -Symmetry sectors an fusion trees · TensorKit.jl

Symmetry sectors an fusion trees

Type hierarchy

TensorKit.SectorType
abstract type Sector end

Abstract type for representing the (isomorphism classes of) simple objects in (unitary and pivotal) (pre-)fusion categories, e.g. the irreducible representations of a finite or compact group. Subtypes I<:Sector as the set of labels of a GradedSpace.

Every new I<:Sector should implement the following methods:

  • one(::Type{I}): unit element of I
  • conj(a::I): $a̅$, conjugate or dual label of $a$
  • ⊗(a::I, b::I): iterable with unique fusion outputs of $a ⊗ b$ (i.e. don't repeat in case of multiplicities)
  • Nsymbol(a::I, b::I, c::I): number of times c appears in a ⊗ b, i.e. the multiplicity
  • FusionStyle(::Type{I}): UniqueFusion(), SimpleFusion() or GenericFusion()
  • BraidingStyle(::Type{I}): Bosonic(), Fermionic(), Anyonic(), ...
  • Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I): F-symbol: scalar (in case of UniqueFusion/SimpleFusion) or matrix (in case of GenericFusion)
  • Rsymbol(a::I, b::I, c::I): R-symbol: scalar (in case of UniqueFusion/SimpleFusion) or matrix (in case of GenericFusion)

and optionally

  • dim(a::I): quantum dimension of sector a
  • frobeniusschur(a::I): Frobenius-Schur indicator of a
  • Bsymbol(a::I, b::I, c::I): B-symbol: scalar (in case of UniqueFusion/SimpleFusion) or matrix (in case of GenericFusion)
  • twist(a::I) -> twist of sector a

and optionally, if FusionStyle(I) isa GenericFusion

  • vertex_ind2label(i::Int, a::I, b::I, c::I) -> a custom label for the ith copy of c appearing in a ⊗ b

Furthermore, iterate and Base.IteratorSize should be made to work for the singleton type SectorValues{I}.

source
TensorKit.SectorValuesType
struct SectorValues{I<:Sector}

Singleton type to represent an iterator over the possible values of type I, whose instance is obtained as values(I). For a new I::Sector, the following should be defined

  • Base.iterate(::SectorValues{I}[, state]): iterate over the values
  • Base.IteratorSize(::Type{SectorValues{I}}): HasLenght(), SizeUnkown() or IsInfinite() depending on whether the number of values of type I is finite (and sufficiently small) or infinite; for a large number of values, SizeUnknown() is recommend because this will trigger the use of GenericGradedSpace.

If IteratorSize(I) == HasLength(), also the following must be implemented:

  • Base.length(::SectorValues{I}): the number of different values
  • Base.getindex(::SectorValues{I}, i::Int): a mapping between an index i and an instance of I
  • findindex(::SectorValues{I}, c::I): reverse mapping between a value c::I and an index i::Integer ∈ 1:length(values(I))
source
TensorKit.FusionStyleType
FusionStyle(a::Sector) -> ::FusionStyle
-FusionStyle(I::Type{<:Sector}) -> ::FusionStyle

Return the type of fusion behavior of sectors of type I, which can be either

  • UniqueFusion(): single fusion output when fusing two sectors;
  • SimpleFusion(): multiple outputs, but every output occurs at most one, also known as multiplicity free (e.g. irreps of $SU(2)$);
  • GenericFusion(): multiple outputs that can occur more than once (e.g. irreps of $SU(3)$).

There is an abstract supertype MultipleFusion of which both SimpleFusion and GenericFusion are subtypes. Furthermore, there is a type alias MultiplicityFreeFusion for those fusion types which do not require muliplicity labels, i.e. MultiplicityFreeFusion = Union{UniqueFusion,SimpleFusion}.

source
TensorKit.BraidingStyleType
BraidingStyle(::Sector) -> ::BraidingStyle
-BraidingStyle(I::Type{<:Sector}) -> ::BraidingStyle

Return the type of braiding and twist behavior of sectors of type I, which can be either

  • Bosonic(): symmetric braiding with trivial twist (i.e. identity)
  • Fermionic(): symmetric braiding with non-trivial twist (squares to identity)
  • Anyonic(): general $R_(a,b)^c$ phase or matrix (depending on SimpleFusion or GenericFusion fusion) and arbitrary twists

Note that Bosonic and Fermionic are subtypes of SymmetricBraiding, which means that braids are in fact equivalent to crossings (i.e. braiding twice is an identity: isone(Rsymbol(b,a,c)*Rsymbol(a,b,c)) == true) and permutations are uniquely defined.

source
TensorKit.AbstractIrrepType
abstract type AbstractIrrep{G<:Group} <: Sector end

Abstract supertype for sectors which corresponds to irreps (irreducible representations) of a group G. As we assume unitary representations, these would be finite groups or compact Lie groups. Note that this could also include projective rather than linear representations.

Actual concrete implementations of those irreps can be obtained as Irrep[G], or via their actual name, which generically takes the form (asciiG)Irrep, i.e. the ASCII spelling of the group name followed by Irrep.

All irreps have BraidingStyle equal to Bosonic() and thus trivial twists.

source
TensorKit.ZNIrrepType
ZNIrrep{N}(n::Integer)
-Irrep[ℤ{N}](n::Integer)

Represents irreps of the group $ℤ_N$ for some value of N<64. (We need 2*(N-1) <= 127 in order for a ⊗ b to work correctly.) For N equals 2, 3 or 4, ℤ{N} can be replaced by ℤ₂, ℤ₃, ℤ₄, whereas Parity is a synonym for Irrep{ℤ₂}. An arbitrary Integer n can be provided to the constructor, but only the value mod(n, N) is relevant.

source
TensorKit.U1IrrepType
U1Irrep(j::Real)
-Irrep[U₁](j::Real)

Represents irreps of the group $U₁$. The irrep is labelled by a charge, which should be an integer for a linear representation. However, it is often useful to allow half integers to represent irreps ofU₁subgroups ofSU₂, such as the Sz of spin-1/2 system. Hence, the charge is stored as aHalfIntfrom the package HalfIntegers.jl, but can be entered as arbitraryReal`. The sequence of the charges is: 0, 1/2, -1/2, 1, -1, ...

source
TensorKit.SU2IrrepType
SU2Irrep(j::Real)
-Irrep[SU₂](j::Real)

Represents irreps of the group $SU₂$. The irrep is labelled by a half integer j which can be entered as an abitrary Real, but is stored as a HalfInt from the HalfIntegers.jl package.

source
TensorKit.CU1IrrepType
CU1Irrep(j, s = ifelse(j>zero(j), 2, 0))
-Irrep[CU₁](j, s = ifelse(j>zero(j), 2, 0))

Represents irreps of the group $U₁ ⋊ C$ ($U₁$ and charge conjugation or reflection), which is also known as just O₂. The irrep is labelled by a positive half integer j (the $U₁$ charge) and an integer s indicating the behaviour under charge conjugation. They take values:

  • if j == 0, s = 0 (trivial charge conjugation) or s = 1 (non-trivial charge conjugation)
  • if j > 0, s = 2 (two-dimensional representation)
source
TensorKit.FermionParityType
FermionParity <: Sector

Represents sectors with fermion parity. The fermion parity is a ℤ₂ quantum number that yields an additional sign when two odd fermions are exchanged.

See also: FermionNumber, FermionSpin

source
TensorKit.FibonacciAnyonType
struct FibonacciAnyon <: Sector
-FibonacciAnyon(s::Symbol)

Represents the anyons (isomorphism classes of simple objects) of the Fibonacci fusion category. It can take two values, corresponding to the trivial sector FibonacciAnyon(:I) and the non-trivial sector FibonacciAnyon(:τ) with fusion rules $τ ⊗ τ = 1 ⊕ τ$.

source
TensorKit.FusionTreeType
struct FusionTree{I, N, M, L, T}

Represents a fusion tree of sectors of type I<:Sector, fusing (or splitting) N uncoupled sectors to a coupled sector. (It actually represents a splitting tree, but fusion tree is a more common term). The isdual field indicates whether an isomorphism is present (if the corresponding value is true) or not. The field uncoupled contains the sectors coming out of the splitting trees, before the possible 𝑍 isomorphism. This fusion tree has M=max(0, N-2) inner lines. Furthermore, for FusionStyle(I) isa GenericFusion, the L=max(0, N-1) corresponding vertices carry a label of type T. If FusionStyle(I) isa MultiplicityFreeFusion,T = Nothing`.

source

Useful constants

TensorKit.IrrepConstant
const Irrep

A constant of a singleton type used as Irrep[G] with G<:Group a type of group, to construct or obtain a concrete subtype of AbstractIrrep{G} that implements the data structure used to represent irreducible representations of the group G.

source

Methods for defining and characterizing Sector subtypes

Base.oneMethod
one(::Sector) -> Sector
-one(::Type{<:Sector}) -> Sector

Return the unit element within this type of sector.

source
TensorKit.NsymbolFunction
Nsymbol(a::I, b::I, c::I) where {I<:Sector} -> Integer

Return an Integer representing the number of times c appears in the fusion product a ⊗ b. Could be a Bool if FusionStyle(I) == UniqueFusion() or SimpleFusion().

source
TensorKit.FsymbolFunction
Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I<:Sector}

Return the F-symbol $F^{abc}_d$ that associates the two different fusion orders of sectors a, b and c into an ouput sector d, using either an intermediate sector $a ⊗ b → e$ or $b ⊗ c → f$:

a-<-μ-<-e-<-ν-<-d                                     a-<-λ-<-d
+Symmetry sectors an fusion trees · TensorKit.jl

Symmetry sectors an fusion trees

Type hierarchy

TensorKit.SectorType
abstract type Sector end

Abstract type for representing the (isomorphism classes of) simple objects in (unitary and pivotal) (pre-)fusion categories, e.g. the irreducible representations of a finite or compact group. Subtypes I<:Sector as the set of labels of a GradedSpace.

Every new I<:Sector should implement the following methods:

  • one(::Type{I}): unit element of I
  • conj(a::I): $a̅$, conjugate or dual label of $a$
  • ⊗(a::I, b::I): iterable with unique fusion outputs of $a ⊗ b$ (i.e. don't repeat in case of multiplicities)
  • Nsymbol(a::I, b::I, c::I): number of times c appears in a ⊗ b, i.e. the multiplicity
  • FusionStyle(::Type{I}): UniqueFusion(), SimpleFusion() or GenericFusion()
  • BraidingStyle(::Type{I}): Bosonic(), Fermionic(), Anyonic(), ...
  • Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I): F-symbol: scalar (in case of UniqueFusion/SimpleFusion) or matrix (in case of GenericFusion)
  • Rsymbol(a::I, b::I, c::I): R-symbol: scalar (in case of UniqueFusion/SimpleFusion) or matrix (in case of GenericFusion)

and optionally

  • dim(a::I): quantum dimension of sector a
  • frobeniusschur(a::I): Frobenius-Schur indicator of a
  • Bsymbol(a::I, b::I, c::I): B-symbol: scalar (in case of UniqueFusion/SimpleFusion) or matrix (in case of GenericFusion)
  • twist(a::I) -> twist of sector a

and optionally, if FusionStyle(I) isa GenericFusion

  • vertex_ind2label(i::Int, a::I, b::I, c::I) -> a custom label for the ith copy of c appearing in a ⊗ b

Furthermore, iterate and Base.IteratorSize should be made to work for the singleton type SectorValues{I}.

source
TensorKit.SectorValuesType
struct SectorValues{I<:Sector}

Singleton type to represent an iterator over the possible values of type I, whose instance is obtained as values(I). For a new I::Sector, the following should be defined

  • Base.iterate(::SectorValues{I}[, state]): iterate over the values
  • Base.IteratorSize(::Type{SectorValues{I}}): HasLenght(), SizeUnkown() or IsInfinite() depending on whether the number of values of type I is finite (and sufficiently small) or infinite; for a large number of values, SizeUnknown() is recommend because this will trigger the use of GenericGradedSpace.

If IteratorSize(I) == HasLength(), also the following must be implemented:

  • Base.length(::SectorValues{I}): the number of different values
  • Base.getindex(::SectorValues{I}, i::Int): a mapping between an index i and an instance of I
  • findindex(::SectorValues{I}, c::I): reverse mapping between a value c::I and an index i::Integer ∈ 1:length(values(I))
source
TensorKit.FusionStyleType
FusionStyle(a::Sector) -> ::FusionStyle
+FusionStyle(I::Type{<:Sector}) -> ::FusionStyle

Return the type of fusion behavior of sectors of type I, which can be either

  • UniqueFusion(): single fusion output when fusing two sectors;
  • SimpleFusion(): multiple outputs, but every output occurs at most one, also known as multiplicity free (e.g. irreps of $SU(2)$);
  • GenericFusion(): multiple outputs that can occur more than once (e.g. irreps of $SU(3)$).

There is an abstract supertype MultipleFusion of which both SimpleFusion and GenericFusion are subtypes. Furthermore, there is a type alias MultiplicityFreeFusion for those fusion types which do not require muliplicity labels, i.e. MultiplicityFreeFusion = Union{UniqueFusion,SimpleFusion}.

source
TensorKit.BraidingStyleType
BraidingStyle(::Sector) -> ::BraidingStyle
+BraidingStyle(I::Type{<:Sector}) -> ::BraidingStyle

Return the type of braiding and twist behavior of sectors of type I, which can be either

  • Bosonic(): symmetric braiding with trivial twist (i.e. identity)
  • Fermionic(): symmetric braiding with non-trivial twist (squares to identity)
  • Anyonic(): general $R_(a,b)^c$ phase or matrix (depending on SimpleFusion or GenericFusion fusion) and arbitrary twists

Note that Bosonic and Fermionic are subtypes of SymmetricBraiding, which means that braids are in fact equivalent to crossings (i.e. braiding twice is an identity: isone(Rsymbol(b,a,c)*Rsymbol(a,b,c)) == true) and permutations are uniquely defined.

source
TensorKit.AbstractIrrepType
abstract type AbstractIrrep{G<:Group} <: Sector end

Abstract supertype for sectors which corresponds to irreps (irreducible representations) of a group G. As we assume unitary representations, these would be finite groups or compact Lie groups. Note that this could also include projective rather than linear representations.

Actual concrete implementations of those irreps can be obtained as Irrep[G], or via their actual name, which generically takes the form (asciiG)Irrep, i.e. the ASCII spelling of the group name followed by Irrep.

All irreps have BraidingStyle equal to Bosonic() and thus trivial twists.

source
TensorKit.ZNIrrepType
ZNIrrep{N}(n::Integer)
+Irrep[ℤ{N}](n::Integer)

Represents irreps of the group $ℤ_N$ for some value of N<64. (We need 2*(N-1) <= 127 in order for a ⊗ b to work correctly.) For N equals 2, 3 or 4, ℤ{N} can be replaced by ℤ₂, ℤ₃, ℤ₄, whereas Parity is a synonym for Irrep{ℤ₂}. An arbitrary Integer n can be provided to the constructor, but only the value mod(n, N) is relevant.

source
TensorKit.U1IrrepType
U1Irrep(j::Real)
+Irrep[U₁](j::Real)

Represents irreps of the group $U₁$. The irrep is labelled by a charge, which should be an integer for a linear representation. However, it is often useful to allow half integers to represent irreps ofU₁subgroups ofSU₂, such as the Sz of spin-1/2 system. Hence, the charge is stored as aHalfIntfrom the package HalfIntegers.jl, but can be entered as arbitraryReal`. The sequence of the charges is: 0, 1/2, -1/2, 1, -1, ...

source
TensorKit.SU2IrrepType
SU2Irrep(j::Real)
+Irrep[SU₂](j::Real)

Represents irreps of the group $SU₂$. The irrep is labelled by a half integer j which can be entered as an abitrary Real, but is stored as a HalfInt from the HalfIntegers.jl package.

source
TensorKit.CU1IrrepType
CU1Irrep(j, s = ifelse(j>zero(j), 2, 0))
+Irrep[CU₁](j, s = ifelse(j>zero(j), 2, 0))

Represents irreps of the group $U₁ ⋊ C$ ($U₁$ and charge conjugation or reflection), which is also known as just O₂. The irrep is labelled by a positive half integer j (the $U₁$ charge) and an integer s indicating the behaviour under charge conjugation. They take values:

  • if j == 0, s = 0 (trivial charge conjugation) or s = 1 (non-trivial charge conjugation)
  • if j > 0, s = 2 (two-dimensional representation)
source
TensorKit.FermionParityType
FermionParity <: Sector

Represents sectors with fermion parity. The fermion parity is a ℤ₂ quantum number that yields an additional sign when two odd fermions are exchanged.

See also: FermionNumber, FermionSpin

source
TensorKit.FibonacciAnyonType
struct FibonacciAnyon <: Sector
+FibonacciAnyon(s::Symbol)

Represents the anyons (isomorphism classes of simple objects) of the Fibonacci fusion category. It can take two values, corresponding to the trivial sector FibonacciAnyon(:I) and the non-trivial sector FibonacciAnyon(:τ) with fusion rules $τ ⊗ τ = 1 ⊕ τ$.

source
TensorKit.FusionTreeType
struct FusionTree{I, N, M, L, T}

Represents a fusion tree of sectors of type I<:Sector, fusing (or splitting) N uncoupled sectors to a coupled sector. (It actually represents a splitting tree, but fusion tree is a more common term). The isdual field indicates whether an isomorphism is present (if the corresponding value is true) or not. The field uncoupled contains the sectors coming out of the splitting trees, before the possible 𝑍 isomorphism. This fusion tree has M=max(0, N-2) inner lines. Furthermore, for FusionStyle(I) isa GenericFusion, the L=max(0, N-1) corresponding vertices carry a label of type T. If FusionStyle(I) isa MultiplicityFreeFusion,T = Nothing`.

source

Useful constants

TensorKit.IrrepConstant
const Irrep

A constant of a singleton type used as Irrep[G] with G<:Group a type of group, to construct or obtain a concrete subtype of AbstractIrrep{G} that implements the data structure used to represent irreducible representations of the group G.

source

Methods for defining and characterizing Sector subtypes

Base.oneMethod
one(::Sector) -> Sector
+one(::Type{<:Sector}) -> Sector

Return the unit element within this type of sector.

source
TensorKit.NsymbolFunction
Nsymbol(a::I, b::I, c::I) where {I<:Sector} -> Integer

Return an Integer representing the number of times c appears in the fusion product a ⊗ b. Could be a Bool if FusionStyle(I) == UniqueFusion() or SimpleFusion().

source
TensorKit.FsymbolFunction
Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I<:Sector}

Return the F-symbol $F^{abc}_d$ that associates the two different fusion orders of sectors a, b and c into an ouput sector d, using either an intermediate sector $a ⊗ b → e$ or $b ⊗ c → f$:

a-<-μ-<-e-<-ν-<-d                                     a-<-λ-<-d
     ∨       ∨       -> Fsymbol(a,b,c,d,e,f)[μ,ν,κ,λ]      ∨
     b       c                                             f
                                                           v
                                                       b-<-κ
                                                           ∨
-                                                          c

If FusionStyle(I) is UniqueFusion or SimpleFusion, the F-symbol is a number. Otherwise it is a rank 4 array of size (Nsymbol(a, b, e), Nsymbol(e, c, d), Nsymbol(b, c, f), Nsymbol(a, f, d)).

source
TensorKit.RsymbolFunction
Rsymbol(a::I, b::I, c::I) where {I<:Sector}

Returns the R-symbol $R^{ab}_c$ that maps between $c → a ⊗ b$ and $c → b ⊗ a$ as in

a -<-μ-<- c                                 b -<-ν-<- c
+                                                          c

If FusionStyle(I) is UniqueFusion or SimpleFusion, the F-symbol is a number. Otherwise it is a rank 4 array of size (Nsymbol(a, b, e), Nsymbol(e, c, d), Nsymbol(b, c, f), Nsymbol(a, f, d)).

source
TensorKit.RsymbolFunction
Rsymbol(a::I, b::I, c::I) where {I<:Sector}

Returns the R-symbol $R^{ab}_c$ that maps between $c → a ⊗ b$ and $c → b ⊗ a$ as in

a -<-μ-<- c                                 b -<-ν-<- c
      ∨          -> Rsymbol(a,b,c)[μ,ν]           v
-     b                                           a

If FusionStyle(I) is UniqueFusion() or SimpleFusion(), the R-symbol is a number. Otherwise it is a square matrix with row and column size Nsymbol(a,b,c) == Nsymbol(b,a,c).

source
TensorKit.BsymbolFunction
Bsymbol(a::I, b::I, c::I) where {I<:Sector}

Return the value of $B^{ab}_c$ which appears in transforming a splitting vertex into a fusion vertex using the transformation

a -<-μ-<- c                                                    a -<-ν-<- c
+     b                                           a

If FusionStyle(I) is UniqueFusion() or SimpleFusion(), the R-symbol is a number. Otherwise it is a square matrix with row and column size Nsymbol(a,b,c) == Nsymbol(b,a,c).

source
TensorKit.BsymbolFunction
Bsymbol(a::I, b::I, c::I) where {I<:Sector}

Return the value of $B^{ab}_c$ which appears in transforming a splitting vertex into a fusion vertex using the transformation

a -<-μ-<- c                                                    a -<-ν-<- c
      ∨          -> √(dim(c)/dim(a)) * Bsymbol(a,b,c)[μ,ν]           ∧
-     b                                                            dual(b)

If FusionStyle(I) is UniqueFusion() or SimpleFusion(), the B-symbol is a number. Otherwise it is a square matrix with row and column size Nsymbol(a, b, c) == Nsymbol(c, dual(b), a).

source
TensorKit.twistFunction
twist(a::Sector)

Return the twist of a sector a

source
twist(t::AbstractTensorMap, i::Int; inv::Bool=false)
-    -> t

Apply a twist to the ith index of t and return the result as a new tensor. If inv=true, use the inverse twist.

See twist! for storing the result in place.

source
Base.isrealMethod
isreal(::Type{<:Sector}) -> Bool

Return whether the topological data (Fsymbol, Rsymbol) of the sector is real or not (in which case it is complex).

source
TensorKit.vertex_ind2labelFunction
vertex_ind2label(k::Int, a::I, b::I, c::I) where {I<:Sector}

Convert the index k of the fusion vertex (a,b)->c into a label. For FusionStyle(I) == UniqueFusion() or FusionStyle(I) == MultipleFusion(), where every fusion output occurs only once and k == 1, the default is to suppress vertex labels by setting them equal to nothing. For FusionStyle(I) == GenericFusion(), the default is to just use k, unless a specialized method is provided.

source
TensorKit.:⊠Method
⊠(s₁::Sector, s₂::Sector)
-deligneproduct(s₁::Sector, s₂::Sector)

Given two sectors s₁ and s₂, which label an isomorphism class of simple objects in a fusion category $C₁$ and $C₂$, s1 ⊠ s2 (obtained as oxtimes+TAB) labels the isomorphism class of simple objects in the Deligne tensor product category $C₁ ⊠ C₂$.

The Deligne tensor product also works in the type domain and for spaces and tensors. For group representations, we have Irrep[G₁] ⊠ Irrep[G₂] == Irrep[G₁ × G₂].

source

Methods for manipulating fusion trees or pairs of fusion-splitting trees

The main method for manipulating a fusion-splitting tree pair is

TensorKit.braidMethod
braid(f₁::FusionTree{I}, f₂::FusionTree{I},
+     b                                                            dual(b)

If FusionStyle(I) is UniqueFusion() or SimpleFusion(), the B-symbol is a number. Otherwise it is a square matrix with row and column size Nsymbol(a, b, c) == Nsymbol(c, dual(b), a).

source
TensorKit.twistFunction
twist(a::Sector)

Return the twist of a sector a

source
twist(t::AbstractTensorMap, i::Int; inv::Bool=false)
+    -> t

Apply a twist to the ith index of t and return the result as a new tensor. If inv=true, use the inverse twist.

See twist! for storing the result in place.

source
Base.isrealMethod
isreal(::Type{<:Sector}) -> Bool

Return whether the topological data (Fsymbol, Rsymbol) of the sector is real or not (in which case it is complex).

source
TensorKit.vertex_ind2labelFunction
vertex_ind2label(k::Int, a::I, b::I, c::I) where {I<:Sector}

Convert the index k of the fusion vertex (a,b)->c into a label. For FusionStyle(I) == UniqueFusion() or FusionStyle(I) == MultipleFusion(), where every fusion output occurs only once and k == 1, the default is to suppress vertex labels by setting them equal to nothing. For FusionStyle(I) == GenericFusion(), the default is to just use k, unless a specialized method is provided.

source
TensorKit.:⊠Method
⊠(s₁::Sector, s₂::Sector)
+deligneproduct(s₁::Sector, s₂::Sector)

Given two sectors s₁ and s₂, which label an isomorphism class of simple objects in a fusion category $C₁$ and $C₂$, s1 ⊠ s2 (obtained as oxtimes+TAB) labels the isomorphism class of simple objects in the Deligne tensor product category $C₁ ⊠ C₂$.

The Deligne tensor product also works in the type domain and for spaces and tensors. For group representations, we have Irrep[G₁] ⊠ Irrep[G₂] == Irrep[G₁ × G₂].

source

Methods for manipulating fusion trees or pairs of fusion-splitting trees

The main method for manipulating a fusion-splitting tree pair is

TensorKit.braidMethod
braid(f₁::FusionTree{I}, f₂::FusionTree{I},
         levels1::IndexTuple, levels2::IndexTuple,
         p1::IndexTuple{N₁}, p2::IndexTuple{N₂}) where {I<:Sector, N₁, N₂}
--> <:AbstractDict{Tuple{FusionTree{I, N₁}, FusionTree{I, N₂}}, <:Number}

Input is a fusion-splitting tree pair that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the splitting tree f₁ and fusion tree f₂, such that the incoming sectors f₂.uncoupled are fused to f₁.coupled == f₂.coupled and then to the outgoing sectors f₁.uncoupled. Compute new trees and corresponding coefficients obtained from repartitioning and braiding the tree such that sectors p1 become outgoing and sectors p2 become incoming. The uncoupled indices in splitting tree f₁ and fusion tree f₂ have levels (or depths) levels1 and levels2 respectively, which determines how indices braid. In particular, if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source

which, for FusionStyle(G) isa SymmetricBraiding, simplifies to

TensorKit.permuteMethod
permute(f₁::FusionTree{I}, f₂::FusionTree{I},
+-> <:AbstractDict{Tuple{FusionTree{I, N₁}, FusionTree{I, N₂}}, <:Number}

Input is a fusion-splitting tree pair that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the splitting tree f₁ and fusion tree f₂, such that the incoming sectors f₂.uncoupled are fused to f₁.coupled == f₂.coupled and then to the outgoing sectors f₁.uncoupled. Compute new trees and corresponding coefficients obtained from repartitioning and braiding the tree such that sectors p1 become outgoing and sectors p2 become incoming. The uncoupled indices in splitting tree f₁ and fusion tree f₂ have levels (or depths) levels1 and levels2 respectively, which determines how indices braid. In particular, if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source

which, for FusionStyle(G) isa SymmetricBraiding, simplifies to

TensorKit.permuteMethod
permute(f₁::FusionTree{I}, f₂::FusionTree{I},
         p1::NTuple{N₁, Int}, p2::NTuple{N₂, Int}) where {I, N₁, N₂}
--> <:AbstractDict{Tuple{FusionTree{I, N₁}, FusionTree{I, N₂}}, <:Number}

Input is a double fusion tree that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the individual trees of outgoing (t1) and incoming sectors (t2) respectively (with identical coupled sector t1.coupled == t2.coupled). Computes new trees and corresponding coefficients obtained from repartitioning and permuting the tree such that sectors p1 become outgoing and sectors p2 become incoming.

source

These operations are implemented by composing the following more elementary manipulations

TensorKit.braidMethod
braid(f::FusionTree{<:Sector, N}, levels::NTuple{N, Int}, p::NTuple{N, Int})
--> <:AbstractDict{typeof(t), <:Number}

Perform a braiding of the uncoupled indices of the fusion tree f and return the result as a <:AbstractDict of output trees and corresponding coefficients. The braiding is determined by specifying that the new sector at position k corresponds to the sector that was originally at the position i = p[k], and assigning to every index i of the original fusion tree a distinct level or depth levels[i]. This permutation is then decomposed into elementary swaps between neighbouring indices, where the swaps are applied as braids such that if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source
TensorKit.permuteMethod
permute(f::FusionTree, p::NTuple{N, Int}) -> <:AbstractDict{typeof(t), <:Number}

Perform a permutation of the uncoupled indices of the fusion tree f and returns the result as a <:AbstractDict of output trees and corresponding coefficients; this requires that BraidingStyle(sectortype(f)) isa SymmetricBraiding.

source
TensorKit.repartitionFunction
repartition(f₁::FusionTree{I, N₁}, f₂::FusionTree{I, N₂}, N::Int) where {I, N₁, N₂}
--> <:AbstractDict{Tuple{FusionTree{I, N}, FusionTree{I, N₁+N₂-N}}, <:Number}

Input is a double fusion tree that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the individual trees of outgoing (f₁) and incoming sectors (f₂) respectively (with identical coupled sector f₁.coupled == f₂.coupled). Computes new trees and corresponding coefficients obtained from repartitioning the tree by bending incoming to outgoing sectors (or vice versa) in order to have N outgoing sectors.

source
TensorKit.artin_braidFunction
artin_braid(f::FusionTree, i; inv::Bool = false) -> <:AbstractDict{typeof(t), <:Number}

Perform an elementary braid (Artin generator) of neighbouring uncoupled indices i and i+1 on a fusion tree f, and returns the result as a dictionary of output trees and corresponding coefficients.

The keyword inv determines whether index i will braid above or below index i+1, i.e. applying artin_braid(f′, i; inv = true) to all the outputs f′ of artin_braid(f, i; inv = false) and collecting the results should yield a single fusion tree with non-zero coefficient, namely f with coefficient 1. This keyword has no effect if BraidingStyle(sectortype(f)) isa SymmetricBraiding.

source

Finally, there are some additional manipulations for internal use

TensorKit.insertatFunction
insertat(f::FusionTree{I, N₁}, i::Int, f₂::FusionTree{I, N₂})
--> <:AbstractDict{<:FusionTree{I, N₁+N₂-1}, <:Number}

Attach a fusion tree f₂ to the uncoupled leg i of the fusion tree f₁ and bring it into a linear combination of fusion trees in standard form. This requires that f₂.coupled == f₁.uncoupled[i] and f₁.isdual[i] == false.

source
TensorKit.splitFunction
split(f::FusionTree{I, N}, M::Int)
--> (::FusionTree{I, M}, ::FusionTree{I, N-M+1})

Split a fusion tree into two. The first tree has as uncoupled sectors the first M uncoupled sectors of the input tree f, whereas its coupled sector corresponds to the internal sector between uncoupled sectors M and M+1 of the original tree f. The second tree has as first uncoupled sector that same internal sector of f, followed by remaining N-M uncoupled sectors of f. It couples to the same sector as f. This operation is the inverse of insertat in the sense that if f₁, f₂ = split(t, M) ⇒ f == insertat(f₂, 1, f₁).

source
TensorKit.mergeFunction
merge(f₁::FusionTree{I, N₁}, f₂::FusionTree{I, N₂}, c::I, μ = nothing)
--> <:AbstractDict{<:FusionTree{I, N₁+N₂}, <:Number}

Merge two fusion trees together to a linear combination of fusion trees whose uncoupled sectors are those of f₁ followed by those of f₂, and where the two coupled sectors of f₁ and f₂ are further fused to c. In case of FusionStyle(I) == GenericFusion(), also a degeneracy label μ for the fusion of the coupled sectors of f₁ and f₂ to c needs to be specified.

source
+-> <:AbstractDict{Tuple{FusionTree{I, N₁}, FusionTree{I, N₂}}, <:Number}

Input is a double fusion tree that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the individual trees of outgoing (t1) and incoming sectors (t2) respectively (with identical coupled sector t1.coupled == t2.coupled). Computes new trees and corresponding coefficients obtained from repartitioning and permuting the tree such that sectors p1 become outgoing and sectors p2 become incoming.

source

These operations are implemented by composing the following more elementary manipulations

TensorKit.braidMethod
braid(f::FusionTree{<:Sector, N}, levels::NTuple{N, Int}, p::NTuple{N, Int})
+-> <:AbstractDict{typeof(t), <:Number}

Perform a braiding of the uncoupled indices of the fusion tree f and return the result as a <:AbstractDict of output trees and corresponding coefficients. The braiding is determined by specifying that the new sector at position k corresponds to the sector that was originally at the position i = p[k], and assigning to every index i of the original fusion tree a distinct level or depth levels[i]. This permutation is then decomposed into elementary swaps between neighbouring indices, where the swaps are applied as braids such that if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source
TensorKit.permuteMethod
permute(f::FusionTree, p::NTuple{N, Int}) -> <:AbstractDict{typeof(t), <:Number}

Perform a permutation of the uncoupled indices of the fusion tree f and returns the result as a <:AbstractDict of output trees and corresponding coefficients; this requires that BraidingStyle(sectortype(f)) isa SymmetricBraiding.

source
TensorKit.repartitionFunction
repartition(f₁::FusionTree{I, N₁}, f₂::FusionTree{I, N₂}, N::Int) where {I, N₁, N₂}
+-> <:AbstractDict{Tuple{FusionTree{I, N}, FusionTree{I, N₁+N₂-N}}, <:Number}

Input is a double fusion tree that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the individual trees of outgoing (f₁) and incoming sectors (f₂) respectively (with identical coupled sector f₁.coupled == f₂.coupled). Computes new trees and corresponding coefficients obtained from repartitioning the tree by bending incoming to outgoing sectors (or vice versa) in order to have N outgoing sectors.

source
TensorKit.artin_braidFunction
artin_braid(f::FusionTree, i; inv::Bool = false) -> <:AbstractDict{typeof(t), <:Number}

Perform an elementary braid (Artin generator) of neighbouring uncoupled indices i and i+1 on a fusion tree f, and returns the result as a dictionary of output trees and corresponding coefficients.

The keyword inv determines whether index i will braid above or below index i+1, i.e. applying artin_braid(f′, i; inv = true) to all the outputs f′ of artin_braid(f, i; inv = false) and collecting the results should yield a single fusion tree with non-zero coefficient, namely f with coefficient 1. This keyword has no effect if BraidingStyle(sectortype(f)) isa SymmetricBraiding.

source

Finally, there are some additional manipulations for internal use

TensorKit.insertatFunction
insertat(f::FusionTree{I, N₁}, i::Int, f₂::FusionTree{I, N₂})
+-> <:AbstractDict{<:FusionTree{I, N₁+N₂-1}, <:Number}

Attach a fusion tree f₂ to the uncoupled leg i of the fusion tree f₁ and bring it into a linear combination of fusion trees in standard form. This requires that f₂.coupled == f₁.uncoupled[i] and f₁.isdual[i] == false.

source
TensorKit.splitFunction
split(f::FusionTree{I, N}, M::Int)
+-> (::FusionTree{I, M}, ::FusionTree{I, N-M+1})

Split a fusion tree into two. The first tree has as uncoupled sectors the first M uncoupled sectors of the input tree f, whereas its coupled sector corresponds to the internal sector between uncoupled sectors M and M+1 of the original tree f. The second tree has as first uncoupled sector that same internal sector of f, followed by remaining N-M uncoupled sectors of f. It couples to the same sector as f. This operation is the inverse of insertat in the sense that if f₁, f₂ = split(t, M) ⇒ f == insertat(f₂, 1, f₁).

source
TensorKit.mergeFunction
merge(f₁::FusionTree{I, N₁}, f₂::FusionTree{I, N₂}, c::I, μ = nothing)
+-> <:AbstractDict{<:FusionTree{I, N₁+N₂}, <:Number}

Merge two fusion trees together to a linear combination of fusion trees whose uncoupled sectors are those of f₁ followed by those of f₂, and where the two coupled sectors of f₁ and f₂ are further fused to c. In case of FusionStyle(I) == GenericFusion(), also a degeneracy label μ for the fusion of the coupled sectors of f₁ and f₂ to c needs to be specified.

source
diff --git a/dev/lib/spaces/index.html b/dev/lib/spaces/index.html index 3585a95a..a050dc33 100644 --- a/dev/lib/spaces/index.html +++ b/dev/lib/spaces/index.html @@ -1,32 +1,32 @@ -Vector spaces · TensorKit.jl

Vector spaces

Type hierarchy

TensorKit.FieldType
abstract type Field end

Abstract type at the top of the type hierarchy for denoting fields over which vector spaces (or more generally, linear categories) can be defined. Two common fields are and , representing the field of real or complex numbers respectively.

source
TensorKit.VectorSpaceType
abstract type VectorSpace end

Abstract type at the top of the type hierarchy for denoting vector spaces, or, more accurately, 𝕜-linear categories. All instances of subtypes of VectorSpace will represent objects in 𝕜-linear monoidal categories.

source
TensorKit.ElementarySpaceType
abstract type ElementarySpace <: VectorSpace end

Elementary finite-dimensional vector space over a field that can be used as the index space corresponding to the indices of a tensor. ElementarySpace is a supertype for all vector spaces (objects) that can be associated with the individual indices of a tensor, as hinted to by its alias IndexSpace.

Every elementary vector space should respond to the methods conj and dual, returning the complex conjugate space and the dual space respectively. The complex conjugate of the dual space is obtained as dual(conj(V)) === conj(dual(V)). These different spaces should be of the same type, so that a tensor can be defined as an element of a homogeneous tensor product of these spaces.

source
TensorKit.GeneralSpaceType
struct GeneralSpace{𝕜} <: ElementarySpace

A finite-dimensional space over an arbitrary field 𝕜 without additional structure. It is thus characterized by its dimension, and whether or not it is the dual and/or conjugate space. For a real field 𝕜, the space and its conjugate are the same.

source
TensorKit.CartesianSpaceType
struct CartesianSpace <: ElementarySpace

A real Euclidean space ℝ^d, which is therefore self-dual. CartesianSpace has no additonal structure and is completely characterised by its dimension d. This is the vector space that is implicitly assumed in most of matrix algebra.

source
TensorKit.ComplexSpaceType
struct ComplexSpace <: ElementarySpace

A standard complex vector space ℂ^d with Euclidean inner product and no additional structure. It is completely characterised by its dimension and whether its the normal space or its dual (which is canonically isomorphic to the conjugate space).

source
TensorKit.GradedSpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+Vector spaces · TensorKit.jl

Vector spaces

Type hierarchy

TensorKit.FieldType
abstract type Field end

Abstract type at the top of the type hierarchy for denoting fields over which vector spaces (or more generally, linear categories) can be defined. Two common fields are and , representing the field of real or complex numbers respectively.

source
TensorKit.VectorSpaceType
abstract type VectorSpace end

Abstract type at the top of the type hierarchy for denoting vector spaces, or, more accurately, 𝕜-linear categories. All instances of subtypes of VectorSpace will represent objects in 𝕜-linear monoidal categories.

source
TensorKit.ElementarySpaceType
abstract type ElementarySpace <: VectorSpace end

Elementary finite-dimensional vector space over a field that can be used as the index space corresponding to the indices of a tensor. ElementarySpace is a supertype for all vector spaces (objects) that can be associated with the individual indices of a tensor, as hinted to by its alias IndexSpace.

Every elementary vector space should respond to the methods conj and dual, returning the complex conjugate space and the dual space respectively. The complex conjugate of the dual space is obtained as dual(conj(V)) === conj(dual(V)). These different spaces should be of the same type, so that a tensor can be defined as an element of a homogeneous tensor product of these spaces.

source
TensorKit.GeneralSpaceType
struct GeneralSpace{𝕜} <: ElementarySpace

A finite-dimensional space over an arbitrary field 𝕜 without additional structure. It is thus characterized by its dimension, and whether or not it is the dual and/or conjugate space. For a real field 𝕜, the space and its conjugate are the same.

source
TensorKit.CartesianSpaceType
struct CartesianSpace <: ElementarySpace

A real Euclidean space ℝ^d, which is therefore self-dual. CartesianSpace has no additonal structure and is completely characterised by its dimension d. This is the vector space that is implicitly assumed in most of matrix algebra.

source
TensorKit.ComplexSpaceType
struct ComplexSpace <: ElementarySpace

A standard complex vector space ℂ^d with Euclidean inner product and no additional structure. It is completely characterised by its dimension and whether its the normal space or its dual (which is canonically isomorphic to the conjugate space).

source
TensorKit.GradedSpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.CompositeSpaceType
abstract type CompositeSpace{S<:ElementarySpace} <: VectorSpace end

Abstract type for composite spaces that are defined in terms of a number of elementary vector spaces of a homogeneous type S<:ElementarySpace.

source
TensorKit.ProductSpaceType
struct ProductSpace{S<:ElementarySpace, N} <: CompositeSpace{S}

A ProductSpace is a tensor product space of N vector spaces of type S<:ElementarySpace. Only tensor products between ElementarySpace objects of the same type are allowed.

source

Useful constants

TensorKit.VectConstant
const Vect

A constant of a singleton type used as Vect[I] with I<:Sector a type of sector, to construct or obtain the concrete type GradedSpace{I,D} instances without having to specify D.

source
TensorKit.RepConstant
const Rep

A constant of a singleton type used as Rep[G] with G<:Group a type of group, to construct or obtain the concrete type GradedSpace{Irrep[G],D} instances without having to specify D. Note that Rep[G] == Vect[Irrep[G]].

See also Irrep and Vect.

source
Missing docstring.

Missing docstring for ZNSpace{N}. Check Documenter's build log for details.

TensorKit.Z2SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.CompositeSpaceType
abstract type CompositeSpace{S<:ElementarySpace} <: VectorSpace end

Abstract type for composite spaces that are defined in terms of a number of elementary vector spaces of a homogeneous type S<:ElementarySpace.

source
TensorKit.ProductSpaceType
struct ProductSpace{S<:ElementarySpace, N} <: CompositeSpace{S}

A ProductSpace is a tensor product space of N vector spaces of type S<:ElementarySpace. Only tensor products between ElementarySpace objects of the same type are allowed.

source

Useful constants

TensorKit.VectConstant
const Vect

A constant of a singleton type used as Vect[I] with I<:Sector a type of sector, to construct or obtain the concrete type GradedSpace{I,D} instances without having to specify D.

source
TensorKit.RepConstant
const Rep

A constant of a singleton type used as Rep[G] with G<:Group a type of group, to construct or obtain the concrete type GradedSpace{Irrep[G],D} instances without having to specify D. Note that Rep[G] == Vect[Irrep[G]].

See also Irrep and Vect.

source
Missing docstring.

Missing docstring for ZNSpace{N}. Check Documenter's build log for details.

TensorKit.Z2SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.Z3SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.Z3SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.Z4SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.Z4SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.U1SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.U1SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.SU2SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.SU2SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.CU1SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source
TensorKit.CU1SpaceType
struct GradedSpace{I<:Sector, D} <: ElementarySpace
     dims::D
     dual::Bool
-end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source

Methods

Methods often apply similar to e.g. spaces and corresponding tensors or tensor maps, e.g.:

TensorKit.fieldFunction
field(V::VectorSpace) -> Field

Return the field type over which a vector space is defined.

source
TensorKit.sectortypeFunction
sectortype(a) -> Type{<:Sector}

Return the type of sector over which object a (e.g. a representation space or a tensor) is defined. Also works in type domain.

source
TensorKit.sectorsFunction
sectors(V::ElementarySpace)

Return an iterator over the different sectors of V.

source
sectors(P::ProductSpace{S, N}) where {S<:ElementarySpace}

Return an iterator over all possible combinations of sectors (represented as an NTuple{N, sectortype(S)}) that can appear within the tensor product space P.

source
TensorKit.hassectorFunction
hassector(V::VectorSpace, a::Sector) -> Bool

Return whether a vector space V has a subspace corresponding to sector a with non-zero dimension, i.e. dim(V, a) > 0.

source
hassector(P::ProductSpace{S, N}, s::NTuple{N, sectortype(S)}) where {S<:ElementarySpace}
--> Bool

Query whether P has a non-zero degeneracy of sector s, representing a combination of sectors on the individual tensor indices.

source
TensorKit.dimFunction
dim(V::VectorSpace) -> Int

Return the total dimension of the vector space V as an Int.

source
TensorKit.dimsFunction
dims(::ProductSpace{S, N}) -> Dims{N} = NTuple{N, Int}

Return the dimensions of the spaces in the tensor product space as a tuple of integers.

source
dims(P::ProductSpace{S, N}, s::NTuple{N, sectortype(S)}) where {S<:ElementarySpace}
--> Dims{N} = NTuple{N, Int}

Return the degeneracy dimensions corresponding to a tuple of sectors s for each of the spaces in the tensor product P.

source
TensorKit.blocksectorsFunction
blocksectors(P::ProductSpace)

Return an iterator over the different unique coupled sector labels, i.e. the different fusion outputs that can be obtained by fusing the sectors present in the different spaces that make up the ProductSpace instance.

source
blocksectors(W::HomSpace)

Return an iterator over the different unique coupled sector labels, i.e. the intersection of the different fusion outputs that can be obtained by fusing the sectors present in the domain, as well as from the codomain.

See also hasblock.

source
TensorKit.blockdimFunction
blockdim(P::ProductSpace, c::Sector)

Return the total dimension of a coupled sector c in the product space, by summing over all dim(P, s) for all tuples of sectors s::NTuple{N, <:Sector} that can fuse to c, counted with the correct multiplicity (i.e. number of ways in which s can fuse to c).

See also hasblock and blocksectors.

source

The following methods act specifically on ElementarySpace spaces:

TensorKit.isdualFunction
isdual(V::ElementarySpace) -> Bool

Return wether an ElementarySpace V is normal or rather a dual space. Always returns false for spaces where V == dual(V).

source
TensorKit.dualFunction
dual(V::VectorSpace) -> VectorSpace

Return the dual space of V; also obtained via V'. This should satisfy dual(dual(V)) == V. It is assumed that typeof(V) == typeof(V').

source
Base.conjFunction
conj(V::S) where {S<:ElementarySpace} -> S

Return the conjugate space of V. This should satisfy conj(conj(V)) == V.

For field(V)==ℝ, conj(V) == V. It is assumed that typeof(V) == typeof(conj(V)).

source
TensorKit.flipFunction
flip(V::S) where {S<:ElementarySpace} -> S

Return a single vector space of type S that has the same value of isdual as dual(V), but yet is isomorphic to V rather than to dual(V). The spaces flip(V) and dual(V) only differ in the case of GradedSpace{I}.

source
TensorKit.:⊕Function
⊕(V₁::S, V₂::S, V₃::S...) where {S<:ElementarySpace} -> S

Return the corresponding vector space of type S that represents the direct sum sum of the spaces V₁, V₂, ... Note that all the individual spaces should have the same value for isdual, as otherwise the direct sum is not defined.

source
Base.oneunitFunction
oneunit(V::S) where {S<:ElementarySpace} -> S

Return the corresponding vector space of type S that represents the trivial one-dimensional space, i.e. the space that is isomorphic to the corresponding field. Note that this is different from one(V::S), which returns the empty product space ProductSpace{S,0}(()).

source
TensorKit.supremumFunction
supremum(V₁::ElementarySpace, V₂::ElementarySpace, V₃::ElementarySpace...)

Return the supremum of a number of elementary spaces, i.e. an instance V::ElementarySpace such that V ≿ V₁, V ≿ V₂, ... and no other W ≺ V has this property. This requires that all arguments have the same value of isdual( ), and also the return value V will have the same value.

source
TensorKit.infimumFunction
infimum(V₁::ElementarySpace, V₂::ElementarySpace, V₃::ElementarySpace...)

Return the infimum of a number of elementary spaces, i.e. an instance V::ElementarySpace such that V ≾ V₁, V ≾ V₂, ... and no other W ≻ V has this property. This requires that all arguments have the same value of isdual( ), and also the return value V will have the same value.

source

while the following also work on both ElementarySpace and ProductSpace

TensorKit.fuseFunction
fuse(V₁::S, V₂::S, V₃::S...) where {S<:ElementarySpace} -> S
-fuse(P::ProductSpace{S}) where {S<:ElementarySpace} -> S

Return a single vector space of type S that is isomorphic to the fusion product of the individual spaces V₁, V₂, ..., or the spaces contained in P.

source
TensorKit.:⊗Function
⊗(V₁::S, V₂::S, V₃::S...) where {S<:ElementarySpace} -> S

Create a ProductSpace{S}(V₁, V₂, V₃...) representing the tensor product of several elementary vector spaces. For convience, Julia's regular multiplication operator * applied to vector spaces has the same effect.

The tensor product structure is preserved, see fuse for returning a single elementary space of type S that is isomorphic to this tensor product.

source
TensorKit.:⊠Function
⊠(s₁::Sector, s₂::Sector)
-deligneproduct(s₁::Sector, s₂::Sector)

Given two sectors s₁ and s₂, which label an isomorphism class of simple objects in a fusion category $C₁$ and $C₂$, s1 ⊠ s2 (obtained as oxtimes+TAB) labels the isomorphism class of simple objects in the Deligne tensor product category $C₁ ⊠ C₂$.

The Deligne tensor product also works in the type domain and for spaces and tensors. For group representations, we have Irrep[G₁] ⊠ Irrep[G₂] == Irrep[G₁ × G₂].

source
⊠(V₁::VectorSpace, V₂::VectorSpace)

Given two vector spaces V₁ and V₂ (ElementarySpace or ProductSpace), or thus, objects of corresponding fusion categories $C₁$ and $C₂$, $V₁ ⊠ V₂$ constructs the Deligne tensor product, an object in $C₁ ⊠ C₂$ which is the natural tensor product of those categories. In particular, the corresponding type of sectors (simple objects) is given by sectortype(V₁ ⊠ V₂) == sectortype(V₁) ⊠ sectortype(V₂) and can be thought of as a tuple of the individual sectors.

The Deligne tensor product also works in the type domain and for sectors and tensors. For group representations, we have Rep[G₁] ⊠ Rep[G₂] == Rep[G₁ × G₂], i.e. these are the natural representation spaces of the direct product of two groups.

source
Base.oneFunction
one(::Sector) -> Sector
-one(::Type{<:Sector}) -> Sector

Return the unit element within this type of sector.

source
one(::S) where {S<:ElementarySpace} -> ProductSpace{S, 0}
-one(::ProductSpace{S}) where {S<:ElementarySpace} -> ProductSpace{S, 0}

Return a tensor product of zero spaces of type S, i.e. this is the unit object under the tensor product operation, such that V ⊗ one(V) == V.

source
TensorKit.ismonomorphicFunction
ismonomorphic(V₁::VectorSpace, V₂::VectorSpace)
-V₁ ≾ V₂

Return whether there exist monomorphisms from V₁ to V₂, i.e. 'injective' morphisms with left inverses.

source
TensorKit.isepimorphicFunction
isepimorphic(V₁::VectorSpace, V₂::VectorSpace)
-V₁ ≿ V₂

Return whether there exist epimorphisms from V₁ to V₂, i.e. 'surjective' morphisms with right inverses.

source
TensorKit.isisomorphicFunction
isisomorphic(V₁::VectorSpace, V₂::VectorSpace)
-V₁ ≅ V₂

Return if V₁ and V₂ are isomorphic, meaning that there exists isomorphisms from V₁ to V₂, i.e. morphisms with left and right inverses.

source
TensorKit.insertunitFunction
insertunit(P::ProductSpace, i::Int = length(P)+1; dual = false, conj = false)

For P::ProductSpace{S,N}, this adds an extra tensor product factor at position 1 <= i <= N+1 (last position by default) which is just the S-equivalent of the underlying field of scalars, i.e. oneunit(S). With the keyword arguments, one can choose to insert the conjugated or dual space instead, which are all isomorphic to the field of scalars.

source
+end

A complex Euclidean space with a direct sum structure corresponding to labels in a set I, the objects of which have the structure of a monoid with respect to a monoidal product . In practice, we restrict the label set to be a set of superselection sectors of type I<:Sector, e.g. the set of distinct irreps of a finite or compact group, or the isomorphism classes of simple objects of a unitary and pivotal (pre-)fusion category.

Here dims represents the degeneracy or multiplicity of every sector.

The data structure D of dims will depend on the result Base.IteratorElsize(values(I)); if the result is of type HasLength or HasShape, dims will be stored in a NTuple{N,Int} with N = length(values(I)). This requires that a sector s::I can be transformed into an index via s == getindex(values(I), i) and i == findindex(values(I), s). If Base.IteratorElsize(values(I)) results IsInfinite() or SizeUnknown(), a SectorDict{I,Int} is used to store the non-zero degeneracy dimensions with the corresponding sector as key. The parameter D is hidden from the user and should typically be of no concern.

The concrete type GradedSpace{I,D} with correct D can be obtained as Vect[I], or if I == Irrep[G] for some G<:Group, as Rep[G].

source

Methods

Methods often apply similar to e.g. spaces and corresponding tensors or tensor maps, e.g.:

TensorKit.fieldFunction
field(V::VectorSpace) -> Field

Return the field type over which a vector space is defined.

source
TensorKit.sectortypeFunction
sectortype(a) -> Type{<:Sector}

Return the type of sector over which object a (e.g. a representation space or a tensor) is defined. Also works in type domain.

source
TensorKit.sectorsFunction
sectors(V::ElementarySpace)

Return an iterator over the different sectors of V.

source
sectors(P::ProductSpace{S, N}) where {S<:ElementarySpace}

Return an iterator over all possible combinations of sectors (represented as an NTuple{N, sectortype(S)}) that can appear within the tensor product space P.

source
TensorKit.hassectorFunction
hassector(V::VectorSpace, a::Sector) -> Bool

Return whether a vector space V has a subspace corresponding to sector a with non-zero dimension, i.e. dim(V, a) > 0.

source
hassector(P::ProductSpace{S, N}, s::NTuple{N, sectortype(S)}) where {S<:ElementarySpace}
+-> Bool

Query whether P has a non-zero degeneracy of sector s, representing a combination of sectors on the individual tensor indices.

source
TensorKit.dimFunction
dim(V::VectorSpace) -> Int

Return the total dimension of the vector space V as an Int.

source
TensorKit.dimsFunction
dims(::ProductSpace{S, N}) -> Dims{N} = NTuple{N, Int}

Return the dimensions of the spaces in the tensor product space as a tuple of integers.

source
dims(P::ProductSpace{S, N}, s::NTuple{N, sectortype(S)}) where {S<:ElementarySpace}
+-> Dims{N} = NTuple{N, Int}

Return the degeneracy dimensions corresponding to a tuple of sectors s for each of the spaces in the tensor product P.

source
TensorKit.blocksectorsFunction
blocksectors(P::ProductSpace)

Return an iterator over the different unique coupled sector labels, i.e. the different fusion outputs that can be obtained by fusing the sectors present in the different spaces that make up the ProductSpace instance.

source
blocksectors(W::HomSpace)

Return an iterator over the different unique coupled sector labels, i.e. the intersection of the different fusion outputs that can be obtained by fusing the sectors present in the domain, as well as from the codomain.

See also hasblock.

source
TensorKit.blockdimFunction
blockdim(P::ProductSpace, c::Sector)

Return the total dimension of a coupled sector c in the product space, by summing over all dim(P, s) for all tuples of sectors s::NTuple{N, <:Sector} that can fuse to c, counted with the correct multiplicity (i.e. number of ways in which s can fuse to c).

See also hasblock and blocksectors.

source

The following methods act specifically on ElementarySpace spaces:

TensorKit.isdualFunction
isdual(V::ElementarySpace) -> Bool

Return wether an ElementarySpace V is normal or rather a dual space. Always returns false for spaces where V == dual(V).

source
TensorKit.dualFunction
dual(V::VectorSpace) -> VectorSpace

Return the dual space of V; also obtained via V'. This should satisfy dual(dual(V)) == V. It is assumed that typeof(V) == typeof(V').

source
Base.conjFunction
conj(V::S) where {S<:ElementarySpace} -> S

Return the conjugate space of V. This should satisfy conj(conj(V)) == V.

For field(V)==ℝ, conj(V) == V. It is assumed that typeof(V) == typeof(conj(V)).

source
TensorKit.flipFunction
flip(V::S) where {S<:ElementarySpace} -> S

Return a single vector space of type S that has the same value of isdual as dual(V), but yet is isomorphic to V rather than to dual(V). The spaces flip(V) and dual(V) only differ in the case of GradedSpace{I}.

source
TensorKit.:⊕Function
⊕(V₁::S, V₂::S, V₃::S...) where {S<:ElementarySpace} -> S

Return the corresponding vector space of type S that represents the direct sum sum of the spaces V₁, V₂, ... Note that all the individual spaces should have the same value for isdual, as otherwise the direct sum is not defined.

source
Base.oneunitFunction
oneunit(V::S) where {S<:ElementarySpace} -> S

Return the corresponding vector space of type S that represents the trivial one-dimensional space, i.e. the space that is isomorphic to the corresponding field. Note that this is different from one(V::S), which returns the empty product space ProductSpace{S,0}(()).

source
TensorKit.supremumFunction
supremum(V₁::ElementarySpace, V₂::ElementarySpace, V₃::ElementarySpace...)

Return the supremum of a number of elementary spaces, i.e. an instance V::ElementarySpace such that V ≿ V₁, V ≿ V₂, ... and no other W ≺ V has this property. This requires that all arguments have the same value of isdual( ), and also the return value V will have the same value.

source
TensorKit.infimumFunction
infimum(V₁::ElementarySpace, V₂::ElementarySpace, V₃::ElementarySpace...)

Return the infimum of a number of elementary spaces, i.e. an instance V::ElementarySpace such that V ≾ V₁, V ≾ V₂, ... and no other W ≻ V has this property. This requires that all arguments have the same value of isdual( ), and also the return value V will have the same value.

source

while the following also work on both ElementarySpace and ProductSpace

TensorKit.fuseFunction
fuse(V₁::S, V₂::S, V₃::S...) where {S<:ElementarySpace} -> S
+fuse(P::ProductSpace{S}) where {S<:ElementarySpace} -> S

Return a single vector space of type S that is isomorphic to the fusion product of the individual spaces V₁, V₂, ..., or the spaces contained in P.

source
TensorKit.:⊗Function
⊗(V₁::S, V₂::S, V₃::S...) where {S<:ElementarySpace} -> S

Create a ProductSpace{S}(V₁, V₂, V₃...) representing the tensor product of several elementary vector spaces. For convience, Julia's regular multiplication operator * applied to vector spaces has the same effect.

The tensor product structure is preserved, see fuse for returning a single elementary space of type S that is isomorphic to this tensor product.

source
TensorKit.:⊠Function
⊠(s₁::Sector, s₂::Sector)
+deligneproduct(s₁::Sector, s₂::Sector)

Given two sectors s₁ and s₂, which label an isomorphism class of simple objects in a fusion category $C₁$ and $C₂$, s1 ⊠ s2 (obtained as oxtimes+TAB) labels the isomorphism class of simple objects in the Deligne tensor product category $C₁ ⊠ C₂$.

The Deligne tensor product also works in the type domain and for spaces and tensors. For group representations, we have Irrep[G₁] ⊠ Irrep[G₂] == Irrep[G₁ × G₂].

source
⊠(V₁::VectorSpace, V₂::VectorSpace)

Given two vector spaces V₁ and V₂ (ElementarySpace or ProductSpace), or thus, objects of corresponding fusion categories $C₁$ and $C₂$, $V₁ ⊠ V₂$ constructs the Deligne tensor product, an object in $C₁ ⊠ C₂$ which is the natural tensor product of those categories. In particular, the corresponding type of sectors (simple objects) is given by sectortype(V₁ ⊠ V₂) == sectortype(V₁) ⊠ sectortype(V₂) and can be thought of as a tuple of the individual sectors.

The Deligne tensor product also works in the type domain and for sectors and tensors. For group representations, we have Rep[G₁] ⊠ Rep[G₂] == Rep[G₁ × G₂], i.e. these are the natural representation spaces of the direct product of two groups.

source
Base.oneFunction
one(::Sector) -> Sector
+one(::Type{<:Sector}) -> Sector

Return the unit element within this type of sector.

source
one(::S) where {S<:ElementarySpace} -> ProductSpace{S, 0}
+one(::ProductSpace{S}) where {S<:ElementarySpace} -> ProductSpace{S, 0}

Return a tensor product of zero spaces of type S, i.e. this is the unit object under the tensor product operation, such that V ⊗ one(V) == V.

source
TensorKit.ismonomorphicFunction
ismonomorphic(V₁::VectorSpace, V₂::VectorSpace)
+V₁ ≾ V₂

Return whether there exist monomorphisms from V₁ to V₂, i.e. 'injective' morphisms with left inverses.

source
TensorKit.isepimorphicFunction
isepimorphic(V₁::VectorSpace, V₂::VectorSpace)
+V₁ ≿ V₂

Return whether there exist epimorphisms from V₁ to V₂, i.e. 'surjective' morphisms with right inverses.

source
TensorKit.isisomorphicFunction
isisomorphic(V₁::VectorSpace, V₂::VectorSpace)
+V₁ ≅ V₂

Return if V₁ and V₂ are isomorphic, meaning that there exists isomorphisms from V₁ to V₂, i.e. morphisms with left and right inverses.

source
TensorKit.insertunitFunction
insertunit(P::ProductSpace, i::Int = length(P)+1; dual = false, conj = false)

For P::ProductSpace{S,N}, this adds an extra tensor product factor at position 1 <= i <= N+1 (last position by default) which is just the S-equivalent of the underlying field of scalars, i.e. oneunit(S). With the keyword arguments, one can choose to insert the conjugated or dual space instead, which are all isomorphic to the field of scalars.

source
diff --git a/dev/lib/tensors/index.html b/dev/lib/tensors/index.html index 3aef606f..9ff33f2a 100644 --- a/dev/lib/tensors/index.html +++ b/dev/lib/tensors/index.html @@ -1,25 +1,25 @@ -Tensors · TensorKit.jl

Tensors

Type hierarchy

TensorKit.AbstractTensorMapType
abstract type AbstractTensorMap{S<:IndexSpace, N₁, N₂} end

Abstract supertype of all tensor maps, i.e. linear maps between tensor products of vector spaces of type S<:IndexSpace. An AbstractTensorMap maps from an input space of type ProductSpace{S, N₂} to an output space of type ProductSpace{S, N₁}.

source
TensorKit.AbstractTensorType
AbstractTensor{S<:IndexSpace, N} = AbstractTensorMap{S, N, 0}

Abstract supertype of all tensors, i.e. elements in the tensor product space of type ProductSpace{S, N}, built from elementary spaces of type S<:IndexSpace.

An AbstractTensor{S, N} is actually a special case AbstractTensorMap{S, N, 0}, i.e. a tensor map with only a non-trivial output space.

source
TensorKit.TensorMapType
struct TensorMap{S<:IndexSpace, N₁, N₂, ...} <: AbstractTensorMap{S, N₁, N₂}

Specific subtype of AbstractTensorMap for representing tensor maps (morphisms in a tensor category) whose data is stored in blocks of some subtype of DenseMatrix.

source

Specific TensorMap constructors

TensorKit.idFunction
id([A::Type{<:DenseMatrix} = Matrix{Float64},] space::VectorSpace) -> TensorMap

Construct the identity endomorphism on space space, i.e. return a t::TensorMap with domain(t) == codomain(t) == V, where storagetype(t) = A can be specified.

source
TensorKit.isomorphismFunction
isomorphism([A::Type{<:DenseMatrix} = Matrix{Float64},]
+Tensors · TensorKit.jl

Tensors

Type hierarchy

TensorKit.AbstractTensorMapType
abstract type AbstractTensorMap{S<:IndexSpace, N₁, N₂} end

Abstract supertype of all tensor maps, i.e. linear maps between tensor products of vector spaces of type S<:IndexSpace. An AbstractTensorMap maps from an input space of type ProductSpace{S, N₂} to an output space of type ProductSpace{S, N₁}.

source
TensorKit.AbstractTensorType
AbstractTensor{S<:IndexSpace, N} = AbstractTensorMap{S, N, 0}

Abstract supertype of all tensors, i.e. elements in the tensor product space of type ProductSpace{S, N}, built from elementary spaces of type S<:IndexSpace.

An AbstractTensor{S, N} is actually a special case AbstractTensorMap{S, N, 0}, i.e. a tensor map with only a non-trivial output space.

source
TensorKit.TensorMapType
struct TensorMap{S<:IndexSpace, N₁, N₂, ...} <: AbstractTensorMap{S, N₁, N₂}

Specific subtype of AbstractTensorMap for representing tensor maps (morphisms in a tensor category) whose data is stored in blocks of some subtype of DenseMatrix.

source

Specific TensorMap constructors

TensorKit.idFunction
id([A::Type{<:DenseMatrix} = Matrix{Float64},] space::VectorSpace) -> TensorMap

Construct the identity endomorphism on space space, i.e. return a t::TensorMap with domain(t) == codomain(t) == V, where storagetype(t) = A can be specified.

source
TensorKit.isomorphismFunction
isomorphism([A::Type{<:DenseMatrix} = Matrix{Float64},]
                 cod::VectorSpace, dom::VectorSpace)
--> TensorMap

Return a t::TensorMap that implements a specific isomorphism between the codomain cod and the domain dom, and for which storagetype(t) can optionally be chosen to be of type A. If the two spaces do not allow for such an isomorphism, and are thus not isomorphic, and error will be thrown. When they are isomorphic, there is no canonical choice for a specific isomorphism, but the current choice is such that isomorphism(cod, dom) == inv(isomorphism(dom, cod)).

See also unitary when InnerProductStyle(cod) === EuclideanProduct().

source
TensorKit.unitaryFunction
unitary([A::Type{<:DenseMatrix} = Matrix{Float64},] cod::VectorSpace, dom::VectorSpace)
--> TensorMap

Return a t::TensorMap that implements a specific unitary isomorphism between the codomain cod and the domain dom, for which spacetype(dom) (== spacetype(cod)) must have an inner product. Furthermore, storagetype(t) can optionally be chosen to be of type A. If the two spaces do not allow for such an isomorphism, and are thus not isomorphic, and error will be thrown. When they are isomorphic, there is no canonical choice for a specific isomorphism, but the current choice is such that unitary(cod, dom) == inv(unitary(dom, cod)) = adjoint(unitary(dom, cod)).

source
TensorKit.isometryFunction
isometry([A::Type{<:DenseMatrix} = Matrix{Float64},] cod::VectorSpace, dom::VectorSpace)
--> TensorMap

Return a t::TensorMap that implements a specific isometry that embeds the domain dom into the codomain cod, and which requires that spacetype(dom) (== spacetype(cod)) has an Euclidean inner product. An isometry t is such that its adjoint t' is the left inverse of t, i.e. t'*t = id(dom), while t*t' is some idempotent endomorphism of cod, i.e. it squares to itself. When dom and cod do not allow for such an isometric inclusion, an error will be thrown.

source

TensorMap operations

Missing docstring.

Missing docstring for permute(t::TensorMap{S}, p1::IndexTuple, p2::IndexTuple) where {S}. Check Documenter's build log for details.

Base.permute!Function
permute!(tdst::AbstractTensorMap{S,N₁,N₂}, tsrc::AbstractTensorMap{S},
+-> TensorMap

Return a t::TensorMap that implements a specific isomorphism between the codomain cod and the domain dom, and for which storagetype(t) can optionally be chosen to be of type A. If the two spaces do not allow for such an isomorphism, and are thus not isomorphic, and error will be thrown. When they are isomorphic, there is no canonical choice for a specific isomorphism, but the current choice is such that isomorphism(cod, dom) == inv(isomorphism(dom, cod)).

See also unitary when InnerProductStyle(cod) === EuclideanProduct().

source
TensorKit.unitaryFunction
unitary([A::Type{<:DenseMatrix} = Matrix{Float64},] cod::VectorSpace, dom::VectorSpace)
+-> TensorMap

Return a t::TensorMap that implements a specific unitary isomorphism between the codomain cod and the domain dom, for which spacetype(dom) (== spacetype(cod)) must have an inner product. Furthermore, storagetype(t) can optionally be chosen to be of type A. If the two spaces do not allow for such an isomorphism, and are thus not isomorphic, and error will be thrown. When they are isomorphic, there is no canonical choice for a specific isomorphism, but the current choice is such that unitary(cod, dom) == inv(unitary(dom, cod)) = adjoint(unitary(dom, cod)).

source
TensorKit.isometryFunction
isometry([A::Type{<:DenseMatrix} = Matrix{Float64},] cod::VectorSpace, dom::VectorSpace)
+-> TensorMap

Return a t::TensorMap that implements a specific isometry that embeds the domain dom into the codomain cod, and which requires that spacetype(dom) (== spacetype(cod)) has an Euclidean inner product. An isometry t is such that its adjoint t' is the left inverse of t, i.e. t'*t = id(dom), while t*t' is some idempotent endomorphism of cod, i.e. it squares to itself. When dom and cod do not allow for such an isometric inclusion, an error will be thrown.

source

TensorMap operations

Missing docstring.

Missing docstring for permute(t::TensorMap{S}, p1::IndexTuple, p2::IndexTuple) where {S}. Check Documenter's build log for details.

Base.permute!Function
permute!(tdst::AbstractTensorMap{S,N₁,N₂}, tsrc::AbstractTensorMap{S},
          (p₁, p₂)::Tuple{IndexTuple{N₁},IndexTuple{N₂}}) where {S,N₁,N₂}
-    -> tdst

Write into tdst the result of permuting the indices of tsrc. The codomain and domain of tdst correspond to the indices in p₁ and p₂ of tsrc respectively.

See permute for creating a new tensor and add_permute! for a more general version.

source
TensorKit.braidFunction
braid(f::FusionTree{<:Sector, N}, levels::NTuple{N, Int}, p::NTuple{N, Int})
--> <:AbstractDict{typeof(t), <:Number}

Perform a braiding of the uncoupled indices of the fusion tree f and return the result as a <:AbstractDict of output trees and corresponding coefficients. The braiding is determined by specifying that the new sector at position k corresponds to the sector that was originally at the position i = p[k], and assigning to every index i of the original fusion tree a distinct level or depth levels[i]. This permutation is then decomposed into elementary swaps between neighbouring indices, where the swaps are applied as braids such that if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source
braid(f₁::FusionTree{I}, f₂::FusionTree{I},
+    -> tdst

Write into tdst the result of permuting the indices of tsrc. The codomain and domain of tdst correspond to the indices in p₁ and p₂ of tsrc respectively.

See permute for creating a new tensor and add_permute! for a more general version.

source
TensorKit.braidFunction
braid(f::FusionTree{<:Sector, N}, levels::NTuple{N, Int}, p::NTuple{N, Int})
+-> <:AbstractDict{typeof(t), <:Number}

Perform a braiding of the uncoupled indices of the fusion tree f and return the result as a <:AbstractDict of output trees and corresponding coefficients. The braiding is determined by specifying that the new sector at position k corresponds to the sector that was originally at the position i = p[k], and assigning to every index i of the original fusion tree a distinct level or depth levels[i]. This permutation is then decomposed into elementary swaps between neighbouring indices, where the swaps are applied as braids such that if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source
braid(f₁::FusionTree{I}, f₂::FusionTree{I},
         levels1::IndexTuple, levels2::IndexTuple,
         p1::IndexTuple{N₁}, p2::IndexTuple{N₂}) where {I<:Sector, N₁, N₂}
--> <:AbstractDict{Tuple{FusionTree{I, N₁}, FusionTree{I, N₂}}, <:Number}

Input is a fusion-splitting tree pair that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the splitting tree f₁ and fusion tree f₂, such that the incoming sectors f₂.uncoupled are fused to f₁.coupled == f₂.coupled and then to the outgoing sectors f₁.uncoupled. Compute new trees and corresponding coefficients obtained from repartitioning and braiding the tree such that sectors p1 become outgoing and sectors p2 become incoming. The uncoupled indices in splitting tree f₁ and fusion tree f₂ have levels (or depths) levels1 and levels2 respectively, which determines how indices braid. In particular, if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source
braid(tsrc::AbstractTensorMap{S}, (p₁, p₂)::Tuple{IndexTuple{N₁},IndexTuple{N₂}}, levels::Tuple;
+-> <:AbstractDict{Tuple{FusionTree{I, N₁}, FusionTree{I, N₂}}, <:Number}

Input is a fusion-splitting tree pair that describes the fusion of a set of incoming uncoupled sectors to a set of outgoing uncoupled sectors, represented using the splitting tree f₁ and fusion tree f₂, such that the incoming sectors f₂.uncoupled are fused to f₁.coupled == f₂.coupled and then to the outgoing sectors f₁.uncoupled. Compute new trees and corresponding coefficients obtained from repartitioning and braiding the tree such that sectors p1 become outgoing and sectors p2 become incoming. The uncoupled indices in splitting tree f₁ and fusion tree f₂ have levels (or depths) levels1 and levels2 respectively, which determines how indices braid. In particular, if i and j cross, $τ_{i,j}$ is applied if levels[i] < levels[j] and $τ_{j,i}^{-1}$ if levels[i] > levels[j]. This does not allow to encode the most general braid, but a general braid can be obtained by combining such operations.

source
braid(tsrc::AbstractTensorMap{S}, (p₁, p₂)::Tuple{IndexTuple{N₁},IndexTuple{N₂}}, levels::Tuple;
       copy::Bool = false) where {S,N₁,N₂}
-    -> tdst::TensorMap{S,N₁,N₂}

Return tensor tdst obtained by braiding the indices of tsrc. The codomain and domain of tdst correspond to the indices in p₁ and p₂ of tsrc respectively. Here, levels is a tuple of length numind(tsrc) that assigns a level or height to the indices of tsrc, which determines whether they will braid over or under any other index with which they have to change places.

If copy=false, tdst might share data with tsrc whenever possible. Otherwise, a copy is always made.

To braid into an existing destination, see braid! and add_braid!

source
TensorKit.braid!Function
braid!(tdst::AbstractTensorMap{S,N₁,N₂}, tsrc::AbstractTensorMap{S},
+    -> tdst::TensorMap{S,N₁,N₂}

Return tensor tdst obtained by braiding the indices of tsrc. The codomain and domain of tdst correspond to the indices in p₁ and p₂ of tsrc respectively. Here, levels is a tuple of length numind(tsrc) that assigns a level or height to the indices of tsrc, which determines whether they will braid over or under any other index with which they have to change places.

If copy=false, tdst might share data with tsrc whenever possible. Otherwise, a copy is always made.

To braid into an existing destination, see braid! and add_braid!

source
TensorKit.braid!Function
braid!(tdst::AbstractTensorMap{S,N₁,N₂}, tsrc::AbstractTensorMap{S},
        (p₁, p₂)::Tuple{IndexTuple{N₁},IndexTuple{N₂}}, levels::Tuple) where {S,N₁,N₂}
-    -> tdst

Write into tdst the result of braiding the indices of tsrc. The codomain and domain of tdst correspond to the indices in p₁ and p₂ of tsrc respectively. Here, levels is a tuple of length numind(tsrc) that assigns a level or height to the indices of tsrc, which determines whether they will braid over or under any other index with which they have to change places.

See braid for creating a new tensor and add_braid! for a more general version.

source
Missing docstring.

Missing docstring for twist. Check Documenter's build log for details.

TensorKit.twist!Function
twist!(t::AbstractTensorMap, i::Int; inv::Bool=false)
-    -> t

Apply a twist to the ith index of t, storing the result in t. If inv=true, use the inverse twist.

See twist for creating a new tensor.

source
Missing docstring.

Missing docstring for add!. Check Documenter's build log for details.

Missing docstring.

Missing docstring for trace!. Check Documenter's build log for details.

Missing docstring.

Missing docstring for contract!. Check Documenter's build log for details.

TensorMap factorizations

TensorKit.leftorthFunction
leftorth(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple;
-            alg::OrthogonalFactorizationAlgorithm = QRpos()) -> Q, R

Create orthonormal basis Q for indices in leftind, and remainder R such that permute(t, (leftind, rightind)) = Q*R.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using leftorth!(t, alg = QRpos()).

Different algorithms are available, namely QR(), QRpos(), SVD() and Polar(). QR() and QRpos() use a standard QR decomposition, producing an upper triangular matrix R. Polar() produces a Hermitian and positive semidefinite R. QRpos() corrects the standard QR decomposition such that the diagonal elements of R are positive. Only QRpos() and Polar() are unique (no residual freedom) so that they always return the same result for the same input tensor t.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and leftorth(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.rightorthFunction
rightorth(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple;
-            alg::OrthogonalFactorizationAlgorithm = LQpos()) -> L, Q

Create orthonormal basis Q for indices in rightind, and remainder L such that permute(t, (leftind, rightind)) = L*Q.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using rightorth!(t, alg = LQpos()).

Different algorithms are available, namely LQ(), LQpos(), RQ(), RQpos(), SVD() and Polar(). LQ() and LQpos() produce a lower triangular matrix L and are computed using a QR decomposition of the transpose. RQ() and RQpos() produce an upper triangular remainder L and only works if the total left dimension is smaller than or equal to the total right dimension. LQpos() and RQpos() add an additional correction such that the diagonal elements of L are positive. Polar() produces a Hermitian and positive semidefinite L. Only LQpos(), RQpos() and Polar() are unique (no residual freedom) so that they always return the same result for the same input tensor t.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and rightorth(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.leftnullFunction
leftnull(t::AbstractTensor, (leftind, rightind)::Index2Tuple;
-            alg::OrthogonalFactorizationAlgorithm = QRpos()) -> N

Create orthonormal basis for the orthogonal complement of the support of the indices in leftind, such that N' * permute(t, (leftind, rightind)) = 0.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using leftnull!(t, alg = QRpos()).

Different algorithms are available, namely QR() (or equivalently, QRpos()), SVD() and SDD(). The first assumes that the matrix is full rank and requires iszero(atol) and iszero(rtol). With SVD() and SDD(), rightnull will use the corresponding singular value decomposition, and one can specify an absolute or relative tolerance for which singular values are to be considered zero, where max(atol, norm(t)*rtol) is used as upper bound.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and leftnull(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.rightnullFunction
rightnull(t::AbstractTensor, (leftind, rightind)::Index2Tuple;
+    -> tdst

Write into tdst the result of braiding the indices of tsrc. The codomain and domain of tdst correspond to the indices in p₁ and p₂ of tsrc respectively. Here, levels is a tuple of length numind(tsrc) that assigns a level or height to the indices of tsrc, which determines whether they will braid over or under any other index with which they have to change places.

See braid for creating a new tensor and add_braid! for a more general version.

source
Missing docstring.

Missing docstring for twist. Check Documenter's build log for details.

TensorKit.twist!Function
twist!(t::AbstractTensorMap, i::Int; inv::Bool=false)
+    -> t

Apply a twist to the ith index of t, storing the result in t. If inv=true, use the inverse twist.

See twist for creating a new tensor.

source
Missing docstring.

Missing docstring for add!. Check Documenter's build log for details.

Missing docstring.

Missing docstring for trace!. Check Documenter's build log for details.

Missing docstring.

Missing docstring for contract!. Check Documenter's build log for details.

TensorMap factorizations

TensorKit.leftorthFunction
leftorth(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple;
+            alg::OrthogonalFactorizationAlgorithm = QRpos()) -> Q, R

Create orthonormal basis Q for indices in leftind, and remainder R such that permute(t, (leftind, rightind)) = Q*R.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using leftorth!(t, alg = QRpos()).

Different algorithms are available, namely QR(), QRpos(), SVD() and Polar(). QR() and QRpos() use a standard QR decomposition, producing an upper triangular matrix R. Polar() produces a Hermitian and positive semidefinite R. QRpos() corrects the standard QR decomposition such that the diagonal elements of R are positive. Only QRpos() and Polar() are unique (no residual freedom) so that they always return the same result for the same input tensor t.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and leftorth(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.rightorthFunction
rightorth(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple;
+            alg::OrthogonalFactorizationAlgorithm = LQpos()) -> L, Q

Create orthonormal basis Q for indices in rightind, and remainder L such that permute(t, (leftind, rightind)) = L*Q.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using rightorth!(t, alg = LQpos()).

Different algorithms are available, namely LQ(), LQpos(), RQ(), RQpos(), SVD() and Polar(). LQ() and LQpos() produce a lower triangular matrix L and are computed using a QR decomposition of the transpose. RQ() and RQpos() produce an upper triangular remainder L and only works if the total left dimension is smaller than or equal to the total right dimension. LQpos() and RQpos() add an additional correction such that the diagonal elements of L are positive. Polar() produces a Hermitian and positive semidefinite L. Only LQpos(), RQpos() and Polar() are unique (no residual freedom) so that they always return the same result for the same input tensor t.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and rightorth(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.leftnullFunction
leftnull(t::AbstractTensor, (leftind, rightind)::Index2Tuple;
+            alg::OrthogonalFactorizationAlgorithm = QRpos()) -> N

Create orthonormal basis for the orthogonal complement of the support of the indices in leftind, such that N' * permute(t, (leftind, rightind)) = 0.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using leftnull!(t, alg = QRpos()).

Different algorithms are available, namely QR() (or equivalently, QRpos()), SVD() and SDD(). The first assumes that the matrix is full rank and requires iszero(atol) and iszero(rtol). With SVD() and SDD(), rightnull will use the corresponding singular value decomposition, and one can specify an absolute or relative tolerance for which singular values are to be considered zero, where max(atol, norm(t)*rtol) is used as upper bound.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and leftnull(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.rightnullFunction
rightnull(t::AbstractTensor, (leftind, rightind)::Index2Tuple;
             alg::OrthogonalFactorizationAlgorithm = LQ(),
             atol::Real = 0.0,
-            rtol::Real = eps(real(float(one(scalartype(t)))))*iszero(atol)) -> N

Create orthonormal basis for the orthogonal complement of the support of the indices in rightind, such that permute(t, (leftind, rightind))*N' = 0.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using rightnull!(t, alg = LQpos()).

Different algorithms are available, namely LQ() (or equivalently, LQpos), SVD() and SDD(). The first assumes that the matrix is full rank and requires iszero(atol) and iszero(rtol). With SVD() and SDD(), rightnull will use the corresponding singular value decomposition, and one can specify an absolute or relative tolerance for which singular values are to be considered zero, where max(atol, norm(t)*rtol) is used as upper bound.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and rightnull(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.tsvdFunction
tsvd(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple;
+            rtol::Real = eps(real(float(one(scalartype(t)))))*iszero(atol)) -> N

Create orthonormal basis for the orthogonal complement of the support of the indices in rightind, such that permute(t, (leftind, rightind))*N' = 0.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using rightnull!(t, alg = LQpos()).

Different algorithms are available, namely LQ() (or equivalently, LQpos), SVD() and SDD(). The first assumes that the matrix is full rank and requires iszero(atol) and iszero(rtol). With SVD() and SDD(), rightnull will use the corresponding singular value decomposition, and one can specify an absolute or relative tolerance for which singular values are to be considered zero, where max(atol, norm(t)*rtol) is used as upper bound.

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and rightnull(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.tsvdFunction
tsvd(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple;
     trunc::TruncationScheme = notrunc(), p::Real = 2, alg::Union{SVD, SDD} = SDD())
-    -> U, S, V, ϵ

Compute the (possibly truncated) singular value decomposition such that norm(permute(t, (leftind, rightind)) - U * S * V) ≈ ϵ, where ϵ thus represents the truncation error.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using tsvd!(t, trunc = notrunc(), p = 2).

A truncation parameter trunc can be specified for the new internal dimension, in which case a truncated singular value decomposition will be computed. Choices are:

  • notrunc(): no truncation (default);
  • truncerr(η::Real): truncates such that the p-norm of the truncated singular values is smaller than η times the p-norm of all singular values;
  • truncdim(χ::Int): truncates such that the equivalent total dimension of the internal vector space is no larger than χ;
  • truncspace(V): truncates such that the dimension of the internal vector space is smaller than that of V in any sector.
  • truncbelow(χ::Real): truncates such that every singular value is larger then χ ;

The method tsvd also returns the truncation error ϵ, computed as the p norm of the singular values that were truncated.

THe keyword alg can be equal to SVD() or SDD(), corresponding to the underlying LAPACK algorithm that computes the decomposition (_gesvd or _gesdd).

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and tsvd(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.eighFunction
eigh(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple) -> D, V

Compute eigenvalue factorization of tensor t as linear map from rightind to leftind. The function eigh assumes that the linear map is hermitian and D and V tensors with the same scalartype as t. See eig and eigen for non-hermitian tensors. Hermiticity requires that the tensor acts on inner product spaces, and the current implementation requires InnerProductStyle(t) === EuclideanProduct().

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using eigh!(t). Note that the permuted tensor on which eigh! is called should have equal domain and codomain, as otherwise the eigenvalue decomposition is meaningless and cannot satisfy

permute(t, (leftind, rightind)) * V = V * D

See also eigen and eig.

source
TensorKit.eigFunction
eig(t::AbstractTensor, (leftind, rightind)::Index2Tuple; kwargs...) -> D, V

Compute eigenvalue factorization of tensor t as linear map from rightind to leftind. The function eig assumes that the linear map is not hermitian and returns type stable complex valued D and V tensors for both real and complex valued t. See eigh for hermitian linear maps

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using eig!(t). Note that the permuted tensor on which eig! is called should have equal domain and codomain, as otherwise the eigenvalue decomposition is meaningless and cannot satisfy

permute(t, (leftind, rightind)) * V = V * D

Accepts the same keyword arguments scale, permute and sortby as eigen of dense matrices. See the corresponding documentation for more information.

See also eigen and eigh.

source
LinearAlgebra.eigenFunction
eigen(t::AbstractTensor, (leftind, rightind)::Index2Tuple; kwargs...) -> D, V

Compute eigenvalue factorization of tensor t as linear map from rightind to leftind.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using eigen!(t). Note that the permuted tensor on which eigen! is called should have equal domain and codomain, as otherwise the eigenvalue decomposition is meaningless and cannot satisfy

permute(t, (leftind, rightind)) * V = V * D

Accepts the same keyword arguments scale, permute and sortby as eigen of dense matrices. See the corresponding documentation for more information.

See also eig and eigh

source
+ -> U, S, V, ϵ

Compute the (possibly truncated) singular value decomposition such that norm(permute(t, (leftind, rightind)) - U * S * V) ≈ ϵ, where ϵ thus represents the truncation error.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using tsvd!(t, trunc = notrunc(), p = 2).

A truncation parameter trunc can be specified for the new internal dimension, in which case a truncated singular value decomposition will be computed. Choices are:

  • notrunc(): no truncation (default);
  • truncerr(η::Real): truncates such that the p-norm of the truncated singular values is smaller than η times the p-norm of all singular values;
  • truncdim(χ::Int): truncates such that the equivalent total dimension of the internal vector space is no larger than χ;
  • truncspace(V): truncates such that the dimension of the internal vector space is smaller than that of V in any sector.
  • truncbelow(χ::Real): truncates such that every singular value is larger then χ ;

The method tsvd also returns the truncation error ϵ, computed as the p norm of the singular values that were truncated.

THe keyword alg can be equal to SVD() or SDD(), corresponding to the underlying LAPACK algorithm that computes the decomposition (_gesvd or _gesdd).

Orthogonality requires InnerProductStyle(t) <: HasInnerProduct, and tsvd(!) is currently only implemented for InnerProductStyle(t) === EuclideanProduct().

source
TensorKit.eighFunction
eigh(t::AbstractTensorMap, (leftind, rightind)::Index2Tuple) -> D, V

Compute eigenvalue factorization of tensor t as linear map from rightind to leftind. The function eigh assumes that the linear map is hermitian and D and V tensors with the same scalartype as t. See eig and eigen for non-hermitian tensors. Hermiticity requires that the tensor acts on inner product spaces, and the current implementation requires InnerProductStyle(t) === EuclideanProduct().

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using eigh!(t). Note that the permuted tensor on which eigh! is called should have equal domain and codomain, as otherwise the eigenvalue decomposition is meaningless and cannot satisfy

permute(t, (leftind, rightind)) * V = V * D

See also eigen and eig.

source
TensorKit.eigFunction
eig(t::AbstractTensor, (leftind, rightind)::Index2Tuple; kwargs...) -> D, V

Compute eigenvalue factorization of tensor t as linear map from rightind to leftind. The function eig assumes that the linear map is not hermitian and returns type stable complex valued D and V tensors for both real and complex valued t. See eigh for hermitian linear maps

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using eig!(t). Note that the permuted tensor on which eig! is called should have equal domain and codomain, as otherwise the eigenvalue decomposition is meaningless and cannot satisfy

permute(t, (leftind, rightind)) * V = V * D

Accepts the same keyword arguments scale, permute and sortby as eigen of dense matrices. See the corresponding documentation for more information.

See also eigen and eigh.

source
LinearAlgebra.eigenFunction
eigen(t::AbstractTensor, (leftind, rightind)::Index2Tuple; kwargs...) -> D, V

Compute eigenvalue factorization of tensor t as linear map from rightind to leftind.

If leftind and rightind are not specified, the current partition of left and right indices of t is used. In that case, less memory is allocated if one allows the data in t to be destroyed/overwritten, by using eigen!(t). Note that the permuted tensor on which eigen! is called should have equal domain and codomain, as otherwise the eigenvalue decomposition is meaningless and cannot satisfy

permute(t, (leftind, rightind)) * V = V * D

Accepts the same keyword arguments scale, permute and sortby as eigen of dense matrices. See the corresponding documentation for more information.

See also eig and eigh

source
diff --git a/dev/man/categories/index.html b/dev/man/categories/index.html index 9190a586..6d0950f1 100644 --- a/dev/man/categories/index.html +++ b/dev/man/categories/index.html @@ -6,4 +6,4 @@ Springer Science & Business Media.
  • kitaev
      Kitaev, A. (2006). Anyons in an exactly solved model and beyond.
             Annals of Physics, 321(1), 2-111.
  • beer
        From categories to anyons: a travelogue
             Kerstin Beer, Dmytro Bondarenko, Alexander Hahn, Maria Kalabakov, Nicole Knust, Laura Niermann, Tobias J. Osborne, Christin Schridde, Stefan Seckmeyer, Deniz E. Stiegemann, and Ramona Wolf
    -        [https://arxiv.org/abs/1811.06670](https://arxiv.org/abs/1811.06670)
  • + [https://arxiv.org/abs/1811.06670](https://arxiv.org/abs/1811.06670) diff --git a/dev/man/intro/index.html b/dev/man/intro/index.html index d4dea010..5263a227 100644 --- a/dev/man/intro/index.html +++ b/dev/man/intro/index.html @@ -1,2 +1,2 @@ -Introduction · TensorKit.jl

    Introduction

    Before providing a typical "user guide" and discussing the implementation of TensorKit.jl on the next pages, let us discuss some of the rationale behind this package.

    What is a tensor?

    At the very start we should ponder about the most suitable and sufficiently general definition of a tensor. A good starting point is the following:

    • A tensor $t$ is an element from the tensor product of $N$ vector spaces $V_1 , V_2, …, V_N$, where $N$ is referred to as the rank or order of the tensor, i.e.

      $t ∈ V_1 ⊗ V_2 ⊗ … ⊗ V_N.$

    If you think of a tensor as an object with indices, a rank $N$ tensor has $N$ indices where every index is associated with the corresponding vector space in that it labels a particular basis in that space. We will return to index notation at the very end of this manual.

    As the tensor product of vector spaces is itself a vector space, this implies that a tensor behaves as a vector, i.e. tensors from the same tensor product space can be added and multiplied by scalars. The tensor product is only defined for vector spaces over the same field of scalars, e.g. there is no meaning in $ℝ^5 ⊗ ℂ^3$. When all the vector spaces in the tensor product have an inner product, this also implies an inner product for the tensor product space. It is hence clear that the different vector spaces in the tensor product should have some form of homogeneity in their structure, yet they do not need to be all equal and can e.g. have different dimensions. It goes without saying that defining the vector spaces and their properties will be an important part of the definition of a tensor. As a consequence, this also constitutes a significant part of the implementation, and is discussed in the section on Vector spaces.

    Aside from the interpretation of a tensor as a vector, we also want to interpret it as a matrix (or more correctly, a linear map) in order to decompose tensors using linear algebra factorisations (e.g. eigenvalue or singular value decomposition). Henceforth, we use the term "tensor map" as follows:

    • A tensor map $t$ is a linear map from a source or domain $W_1 ⊗ W_2 ⊗ … ⊗ W_{N_2}$ to a target or codomain $V_1 ⊗ V_2 ⊗ … ⊗ V_{N_1}$, i.e.

      $t:W_1 ⊗ W_2 ⊗ … ⊗ W_{N_2} → V_1 ⊗ V_2 ⊗ … ⊗ V_{N_1}.$

    A tensor of rank $N$ is then just a special case of a tensor map with $N_1 = N$ and $N_2 = 0$. A contraction between two tensors is just a composition of linear maps (i.e. matrix multiplication), where the contracted indices correspond to the domain of the first tensor and the codomain of the second tensor.

    In order to allow for arbitrary tensor contractions or decompositions, we need to be able to reorganise which vector spaces appear in the domain and the codomain of the tensor map, and in which order. This amounts to defining canonical isomorphisms between the different ways to order and partition the tensor indices (i.e. the vector spaces). For example, a linear map $W → V$ is often denoted as a rank 2 tensor in $V ⊗ W^*$, where $W^*$ corresponds to the dual space of $W$. This simple example introduces two new concepts.

    1. Typical vector spaces can appear in the domain and codomain in different related forms, e.g. as normal space or dual space. In fact, the most generic case is that every vector space $V$ has associated with it a dual space $V^*$, a conjugate space $\overline{V}$ and a conjugate dual space $\overline{V}^*$. The four different vector spaces $V$, $V^*$, $\overline{V}$ and $\overline{V}^*$ correspond to the representation spaces of respectively the fundamental, dual or contragredient, complex conjugate and dual complex conjugate representation of the general linear group $\mathsf{GL}(V)$. In index notation these spaces are denoted with respectively contravariant (upper), covariant (lower), dotted contravariant and dotted covariant indices.

      For real vector spaces, the conjugate (dual) space is identical to the normal (dual) space and we only have upper and lower indices, i.e. this is the setting of e.g. general relativity. For (complex) vector spaces with a sesquilinear inner product $\overline{V} ⊗ V → ℂ$, the inner product allows to define an isomorphism from the conjugate space to the dual space (known as Riesz representation theorem in the more general context of Hilbert spaces).

      In particular, in spaces with a Euclidean inner product (the setting of e.g. quantum mechanics), the conjugate and dual space are naturally isomorphic (because the dual and conjugate representation of the unitary group are the same). Again we only need upper and lower indices (or kets and bras).

      Finally, in $ℝ^d$ with a Euclidean inner product, these four different spaces are all equivalent and we only need one type of index. The space is completely characterized by its dimension $d$. This is the setting of much of classical mechanics and we refer to such tensors as cartesian tensors and the corresponding space as cartesian space. These are the tensors that can equally well be represented as multidimensional arrays (i.e. using some AbstractArray{<:Real,N} in Julia) without loss of structure.

      The implementation of all of this is discussed in Vector spaces.

    2. In the generic case, the identification between maps $W → V$ and tensors in $V ⊗ W^*$ is not an equivalence but an isomorphism, which needs to be defined. Similarly, there is an isomorphism between between $V ⊗ W$ and $W ⊗ V$ that can be non-trivial (e.g. in the case of fermions / super vector spaces). The correct formalism here is provided by theory of monoidal categories, which is introduced on the next page. Nonetheless, we try to hide these canonical isomorphisms from the user wherever possible, and one does not need to know category theory to be able to use this package.

    This brings us to our final (yet formal) definition

    • A tensor (map) is a homomorphism between two objects from the category $\mathbf{Vect}$ (or some subcategory thereof). In practice, this will be $\mathbf{FinVect}$, the category of finite dimensional vector spaces. More generally even, our concept of a tensor makes sense, in principle, for any linear (a.k.a. $\mathbf{Vect}$-enriched) monoidal category. We refer to the next page on "Monoidal categories and their properties".

    Symmetries and block sparsity

    Physical problems often have some symmetry, i.e. the setup is invariant under the action of a group $\mathsf{G}$ which acts on the vector spaces $V$ in the problem according to a certain representation. Having quantum mechanics in mind, TensorKit.jl is so far restricted to unitary representations. A general representation space $V$ can be specified as the number of times every irreducible representation (irrep) $a$ of $\mathsf{G}$ appears, i.e.

    $V = \bigoplus_{a} ℂ^{n_a} ⊗ R_a$

    with $R_a$ the space associated with irrep $a$ of $\mathsf{G}$, which itself has dimension $d_a$ (often called the quantum dimension), and $n_a$ the number of times this irrep appears in $V$. If the unitary irrep $a$ for $g ∈ \mathsf{G}$ is given by $u_a(g)$, then there exists a specific basis for $V$ such that the group action of $\mathsf{G}$ on $V$ is given by the unitary representation

    $u(g) = \bigoplus_{a} 𝟙_{n_a} ⊗ u_a(g)$

    with $𝟙_{n_a}$ the $n_a × n_a$ identity matrix. The total dimension of $V$ is given by $∑_a n_a d_a$.

    The reason for implementing symmetries is to exploit the computation and memory gains resulting from restricting to tensor maps $t:W_1 ⊗ W_2 ⊗ … ⊗ W_{N_2} → V_1 ⊗ V_2 ⊗ … ⊗ V_{N_1}$ that are equivariant under the symmetry, i.e. that act as intertwiners between the symmetry action on the domain and the codomain. Indeed, such tensors should be block diagonal because of Schur's lemma, but only after we couple the individual irreps in the spaces $W_i$ to a joint irrep, which is then again split into the individual irreps of the spaces $V_i$. The basis change from the tensor product of irreps in the (co)domain to the joint irrep is implemented by a sequence of Clebsch–Gordan coefficients, also known as a fusion (or splitting) tree. We implement the necessary machinery to manipulate these fusion trees under index permutations and repartitions for arbitrary groups $\mathsf{G}$. In particular, this fits with the formalism of monoidal categories, and more specifically fusion categories, and only requires the topological data of the group, i.e. the fusion rules of the irreps, their quantum dimensions and the F-symbol (6j-symbol or more precisely Racah's W-symbol in the case of $\mathsf{SU}_2$). In particular, we don't actually need the Clebsch–Gordan coefficients themselves (but they can be useful for checking purposes).

    Hence, a second major part of TensorKit.jl is the interface and implementation for specifying symmetries, and further details are provided in Sectors, representation spaces and fusion trees.

    +Introduction · TensorKit.jl

    Introduction

    Before providing a typical "user guide" and discussing the implementation of TensorKit.jl on the next pages, let us discuss some of the rationale behind this package.

    What is a tensor?

    At the very start we should ponder about the most suitable and sufficiently general definition of a tensor. A good starting point is the following:

    • A tensor $t$ is an element from the tensor product of $N$ vector spaces $V_1 , V_2, …, V_N$, where $N$ is referred to as the rank or order of the tensor, i.e.

      $t ∈ V_1 ⊗ V_2 ⊗ … ⊗ V_N.$

    If you think of a tensor as an object with indices, a rank $N$ tensor has $N$ indices where every index is associated with the corresponding vector space in that it labels a particular basis in that space. We will return to index notation at the very end of this manual.

    As the tensor product of vector spaces is itself a vector space, this implies that a tensor behaves as a vector, i.e. tensors from the same tensor product space can be added and multiplied by scalars. The tensor product is only defined for vector spaces over the same field of scalars, e.g. there is no meaning in $ℝ^5 ⊗ ℂ^3$. When all the vector spaces in the tensor product have an inner product, this also implies an inner product for the tensor product space. It is hence clear that the different vector spaces in the tensor product should have some form of homogeneity in their structure, yet they do not need to be all equal and can e.g. have different dimensions. It goes without saying that defining the vector spaces and their properties will be an important part of the definition of a tensor. As a consequence, this also constitutes a significant part of the implementation, and is discussed in the section on Vector spaces.

    Aside from the interpretation of a tensor as a vector, we also want to interpret it as a matrix (or more correctly, a linear map) in order to decompose tensors using linear algebra factorisations (e.g. eigenvalue or singular value decomposition). Henceforth, we use the term "tensor map" as follows:

    • A tensor map $t$ is a linear map from a source or domain $W_1 ⊗ W_2 ⊗ … ⊗ W_{N_2}$ to a target or codomain $V_1 ⊗ V_2 ⊗ … ⊗ V_{N_1}$, i.e.

      $t:W_1 ⊗ W_2 ⊗ … ⊗ W_{N_2} → V_1 ⊗ V_2 ⊗ … ⊗ V_{N_1}.$

    A tensor of rank $N$ is then just a special case of a tensor map with $N_1 = N$ and $N_2 = 0$. A contraction between two tensors is just a composition of linear maps (i.e. matrix multiplication), where the contracted indices correspond to the domain of the first tensor and the codomain of the second tensor.

    In order to allow for arbitrary tensor contractions or decompositions, we need to be able to reorganise which vector spaces appear in the domain and the codomain of the tensor map, and in which order. This amounts to defining canonical isomorphisms between the different ways to order and partition the tensor indices (i.e. the vector spaces). For example, a linear map $W → V$ is often denoted as a rank 2 tensor in $V ⊗ W^*$, where $W^*$ corresponds to the dual space of $W$. This simple example introduces two new concepts.

    1. Typical vector spaces can appear in the domain and codomain in different related forms, e.g. as normal space or dual space. In fact, the most generic case is that every vector space $V$ has associated with it a dual space $V^*$, a conjugate space $\overline{V}$ and a conjugate dual space $\overline{V}^*$. The four different vector spaces $V$, $V^*$, $\overline{V}$ and $\overline{V}^*$ correspond to the representation spaces of respectively the fundamental, dual or contragredient, complex conjugate and dual complex conjugate representation of the general linear group $\mathsf{GL}(V)$. In index notation these spaces are denoted with respectively contravariant (upper), covariant (lower), dotted contravariant and dotted covariant indices.

      For real vector spaces, the conjugate (dual) space is identical to the normal (dual) space and we only have upper and lower indices, i.e. this is the setting of e.g. general relativity. For (complex) vector spaces with a sesquilinear inner product $\overline{V} ⊗ V → ℂ$, the inner product allows to define an isomorphism from the conjugate space to the dual space (known as Riesz representation theorem in the more general context of Hilbert spaces).

      In particular, in spaces with a Euclidean inner product (the setting of e.g. quantum mechanics), the conjugate and dual space are naturally isomorphic (because the dual and conjugate representation of the unitary group are the same). Again we only need upper and lower indices (or kets and bras).

      Finally, in $ℝ^d$ with a Euclidean inner product, these four different spaces are all equivalent and we only need one type of index. The space is completely characterized by its dimension $d$. This is the setting of much of classical mechanics and we refer to such tensors as cartesian tensors and the corresponding space as cartesian space. These are the tensors that can equally well be represented as multidimensional arrays (i.e. using some AbstractArray{<:Real,N} in Julia) without loss of structure.

      The implementation of all of this is discussed in Vector spaces.

    2. In the generic case, the identification between maps $W → V$ and tensors in $V ⊗ W^*$ is not an equivalence but an isomorphism, which needs to be defined. Similarly, there is an isomorphism between between $V ⊗ W$ and $W ⊗ V$ that can be non-trivial (e.g. in the case of fermions / super vector spaces). The correct formalism here is provided by theory of monoidal categories, which is introduced on the next page. Nonetheless, we try to hide these canonical isomorphisms from the user wherever possible, and one does not need to know category theory to be able to use this package.

    This brings us to our final (yet formal) definition

    • A tensor (map) is a homomorphism between two objects from the category $\mathbf{Vect}$ (or some subcategory thereof). In practice, this will be $\mathbf{FinVect}$, the category of finite dimensional vector spaces. More generally even, our concept of a tensor makes sense, in principle, for any linear (a.k.a. $\mathbf{Vect}$-enriched) monoidal category. We refer to the next page on "Monoidal categories and their properties".

    Symmetries and block sparsity

    Physical problems often have some symmetry, i.e. the setup is invariant under the action of a group $\mathsf{G}$ which acts on the vector spaces $V$ in the problem according to a certain representation. Having quantum mechanics in mind, TensorKit.jl is so far restricted to unitary representations. A general representation space $V$ can be specified as the number of times every irreducible representation (irrep) $a$ of $\mathsf{G}$ appears, i.e.

    $V = \bigoplus_{a} ℂ^{n_a} ⊗ R_a$

    with $R_a$ the space associated with irrep $a$ of $\mathsf{G}$, which itself has dimension $d_a$ (often called the quantum dimension), and $n_a$ the number of times this irrep appears in $V$. If the unitary irrep $a$ for $g ∈ \mathsf{G}$ is given by $u_a(g)$, then there exists a specific basis for $V$ such that the group action of $\mathsf{G}$ on $V$ is given by the unitary representation

    $u(g) = \bigoplus_{a} 𝟙_{n_a} ⊗ u_a(g)$

    with $𝟙_{n_a}$ the $n_a × n_a$ identity matrix. The total dimension of $V$ is given by $∑_a n_a d_a$.

    The reason for implementing symmetries is to exploit the computation and memory gains resulting from restricting to tensor maps $t:W_1 ⊗ W_2 ⊗ … ⊗ W_{N_2} → V_1 ⊗ V_2 ⊗ … ⊗ V_{N_1}$ that are equivariant under the symmetry, i.e. that act as intertwiners between the symmetry action on the domain and the codomain. Indeed, such tensors should be block diagonal because of Schur's lemma, but only after we couple the individual irreps in the spaces $W_i$ to a joint irrep, which is then again split into the individual irreps of the spaces $V_i$. The basis change from the tensor product of irreps in the (co)domain to the joint irrep is implemented by a sequence of Clebsch–Gordan coefficients, also known as a fusion (or splitting) tree. We implement the necessary machinery to manipulate these fusion trees under index permutations and repartitions for arbitrary groups $\mathsf{G}$. In particular, this fits with the formalism of monoidal categories, and more specifically fusion categories, and only requires the topological data of the group, i.e. the fusion rules of the irreps, their quantum dimensions and the F-symbol (6j-symbol or more precisely Racah's W-symbol in the case of $\mathsf{SU}_2$). In particular, we don't actually need the Clebsch–Gordan coefficients themselves (but they can be useful for checking purposes).

    Hence, a second major part of TensorKit.jl is the interface and implementation for specifying symmetries, and further details are provided in Sectors, representation spaces and fusion trees.

    diff --git a/dev/man/sectors/index.html b/dev/man/sectors/index.html index 5c1d2c51..0351cfe9 100644 --- a/dev/man/sectors/index.html +++ b/dev/man/sectors/index.html @@ -244,7 +244,7 @@ FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2, 1/2), 1/2, (true, false, false, true, false), (0, 1/2, 1)) FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2, 1/2), 1/2, (true, false, false, true, false), (1, 1/2, 0)) FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2, 1/2), 1/2, (true, false, false, true, false), (1, 1/2, 1)) - FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2, 1/2), 1/2, (true, false, false, true, false), (1, 3/2, 1))
    julia> iter = fusiontrees(ntuple(n->s, 16))TensorKit.FusionTreeIterator{SU2Irrep, 16}((Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2)), Irrep[SU₂](0), (false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false))
    julia> sum(n->1, iter)1430
    julia> length(iter)1430
    julia> @elapsed sum(n->1, iter)0.040903407
    julia> @elapsed length(iter)9.5901e-5
    julia> s2 = s ⊠ s(Irrep[SU₂](1/2) ⊠ Irrep[SU₂](1/2))
    julia> collect(fusiontrees((s2,s2,s2,s2)))4-element Vector{FusionTree{TensorKit.ProductSector{Tuple{SU2Irrep, SU2Irrep}}, 4, 2, 3, Nothing}}: + FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2, 1/2), 1/2, (true, false, false, true, false), (1, 3/2, 1))
    julia> iter = fusiontrees(ntuple(n->s, 16))TensorKit.FusionTreeIterator{SU2Irrep, 16}((Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2), Irrep[SU₂](1/2)), Irrep[SU₂](0), (false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false))
    julia> sum(n->1, iter)1430
    julia> length(iter)1430
    julia> @elapsed sum(n->1, iter)0.030531781
    julia> @elapsed length(iter)9.0428e-5
    julia> s2 = s ⊠ s(Irrep[SU₂](1/2) ⊠ Irrep[SU₂](1/2))
    julia> collect(fusiontrees((s2,s2,s2,s2)))4-element Vector{FusionTree{TensorKit.ProductSector{Tuple{SU2Irrep, SU2Irrep}}, 4, 2, 3, Nothing}}: FusionTree{Irrep[SU₂ × SU₂]}(((1/2, 1/2), (1/2, 1/2), (1/2, 1/2), (1/2, 1/2)), (0, 0), (false, false, false, false), ((0, 0), (1/2, 1/2))) FusionTree{Irrep[SU₂ × SU₂]}(((1/2, 1/2), (1/2, 1/2), (1/2, 1/2), (1/2, 1/2)), (0, 0), (false, false, false, false), ((1, 0), (1/2, 1/2))) FusionTree{Irrep[SU₂ × SU₂]}(((1/2, 1/2), (1/2, 1/2), (1/2, 1/2), (1/2, 1/2)), (0, 0), (false, false, false, false), ((0, 1), (1/2, 1/2))) @@ -311,13 +311,13 @@ < FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (0, 1/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2))> = 0.0 < FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (0, 1/2))> = 0.0 < FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2))> = 3.0 -< FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2))> = 1.7569089568055032e-17 +< FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2))> = 0.0 < FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (0, 1/2))> = 0.0 -< FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2))> = 1.7569089568055032e-17 +< FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 1/2))> = 0.0 < FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2)), FusionTree{Irrep[SU₂]}((1/2, 1/2, 1/2, 1/2), 1, (false, false, false, false), (1, 3/2))> = 3.0

    Note that we take the adjoint when computing Z, because convert(Array, f) assumes f to be splitting tree, which is built using $Z^†$. Further note that the normalization (squared) of a fusion tree is given by the dimension of the coupled sector, as we are also tracing over the $\mathrm{id}_c$ when checking the orthogonality by computing dot of the corresponding tensors.

    Fermions

    TODO: Update the documentation for this section.

    Fermionic sectors are represented by the type FermionParity, which effectively behaves like a ℤ₂ sector, but with two modifications. Firstly, the exchange of two sectors with odd fermion parity should yield a minus sign, which is taken care of by virtue of the R-symbol. This ensures that permuting tensors behave as expected. Secondly, diagrams with self-crossing lines (aka twists) give rise to a minus sign for odd fermion parity. This is in essence equivalent to having supertraces, which is what ensures that @tensor has a result that is invariant under permutation of its input tensors. This does however lead to unwanted minus signs for certain types of diagrams. To avoid this, the @planar macro does not include a supertrace, but requires a manual resolution of all crossings in the diagram.

    Anyons

    There is currently one example of a Sector subtype that has anyonic braiding style, namely that of the Fibonacci fusion category. It has to (isomorphism classes of) simple objects, namely the identity 𝟙 and a non-trivial object known as τ, with fusion rules τ ⊗ τ = 𝟙 ⊕ τ. Let's summarize the topological data

    julia> 𝟙 = FibonacciAnyon(:I)FibonacciAnyon(:I)
    julia> τ = FibonacciAnyon(:τ)FibonacciAnyon(:τ)
    julia> collect(τ ⊗ τ)2-element Vector{FibonacciAnyon}: :I :τ
    julia> FusionStyle(τ)SimpleFusion()
    julia> BraidingStyle(τ)Anyonic()
    julia> dim(𝟙)1.0
    julia> dim(τ)1.618033988749895
    julia> F𝟙 = Fsymbol(τ,τ,τ,𝟙,τ,τ)1.0
    julia> Fτ = [Fsymbol(τ,τ,τ,τ,𝟙,𝟙) Fsymbol(τ,τ,τ,τ,𝟙,τ); Fsymbol(τ,τ,τ,τ,τ,𝟙) Fsymbol(τ,τ,τ,τ,τ,τ)]2×2 Matrix{Float64}: 0.618034 0.786151 0.786151 -0.618034
    julia> Fτ'*Fτ2×2 Matrix{Float64}: 1.0 0.0 - 0.0 1.0
    julia> polar(x) = rationalize.((abs(x), angle(x)/(2pi)))polar (generic function with 1 method)
    julia> Rsymbol(τ,τ,𝟙) |> polar(1//1, 2//5)
    julia> Rsymbol(τ,τ,τ) |> polar(1//1, -3//10)
    julia> twist(τ) |> polar(1//1, -2//5)
    + 0.0 1.0
    julia> polar(x) = rationalize.((abs(x), angle(x)/(2pi)))polar (generic function with 1 method)
    julia> Rsymbol(τ,τ,𝟙) |> polar(1//1, 2//5)
    julia> Rsymbol(τ,τ,τ) |> polar(1//1, -3//10)
    julia> twist(τ) |> polar(1//1, -2//5) diff --git a/dev/man/spaces/index.html b/dev/man/spaces/index.html index 0e6a4226..e5984b48 100644 --- a/dev/man/spaces/index.html +++ b/dev/man/spaces/index.html @@ -31,4 +31,4 @@ codomain::P1 domain::P2 end

    and can create it as either domain → codomain or codomain ← domain (where the arrows are obtained as \to+TAB or \leftarrow+TAB, and as \rightarrow+TAB respectively). The reason for first listing the codomain and than the domain will become clear in the section on tensor maps.

    Note that HomSpace is not a subtype of VectorSpace, i.e. we restrict the latter to denote certain categories and their objects, and keep HomSpace distinct. However, HomSpace has a number of properties defined, which we illustrate via examples

    julia> W = ℂ^2 ⊗ ℂ^3 → ℂ^3 ⊗ dual(ℂ^4)(ℂ^3 ⊗ (ℂ^4)') ← (ℂ^2 ⊗ ℂ^3)
    julia> field(W)
    julia> dual(W)((ℂ^3)' ⊗ (ℂ^2)') ← (ℂ^4 ⊗ (ℂ^3)')
    julia> adjoint(W)(ℂ^2 ⊗ ℂ^3) ← (ℂ^3 ⊗ (ℂ^4)')
    julia> spacetype(W)ComplexSpace
    julia> spacetype(typeof(W))ComplexSpace
    julia> W[1]ℂ^3
    julia> W[2](ℂ^4)'
    julia> W[3](ℂ^2)'
    julia> W[4](ℂ^3)'
    julia> dim(W)72

    Note that indexing W yields first the spaces in the codomain, followed by the dual of the spaces in the domain. This particular convention is useful in combination with the instances of type TensorMap, which represent morphisms living in such a HomSpace. Also note that dim(W) here seems to be the product of the dimensions of the individual spaces, but that this is no longer true once symmetries are involved. At any time will dim(::HomSpace) represent the number of linearly independent morphisms in this space.

    Partial order among vector spaces

    Vector spaces of the same spacetype can be given a partial order, based on whether there exist injective morphisms (a.k.a monomorphisms) or surjective morphisms (a.k.a. epimorphisms) between them. In particular, we define ismonomorphic(V1, V2), with Unicode synonym V1 ≾ V2 (obtained as \precsim+TAB), to express whether there exist monomorphisms in V1→V2. Similarly, we define isepimorphic(V1, V2), with Unicode synonym V1 ≿ V2 (obtained as \succsim+TAB), to express whether there exist epimorphisms in V1→V2. Finally, we define isisomorphic(V1, V2), with Unicode alternative V1 ≅ V2 (obtained as \cong+TAB), to express whether there exist isomorphism in V1→V2. In particular V1 ≅ V2 if and only if V1 ≾ V2 && V1 ≿ V2.

    For completeness, we also export the strict comparison operators and (\prec+TAB and \succ+TAB), with definitions

    ≺(V1::VectorSpace, V2::VectorSpace) = V1 ≾ V2 && !(V1 ≿ V2)
    -≻(V1::VectorSpace, V2::VectorSpace) = V1 ≿ V2 && !(V1 ≾ V2)

    However, as we expect these to be less commonly used, no ASCII alternative is provided.

    In the context of InnerProductStyle(V) <: EuclideanProduct, V1 ≾ V2 implies that there exists isometries $W:V1 → V2$ such that $W^† ∘ W = \mathrm{id}_{V1}$, while V1 ≅ V2 implies that there exist unitaries $U:V1→V2$ such that $U^† ∘ U = \mathrm{id}_{V1}$ and $U ∘ U^† = \mathrm{id}_{V2}$.

    Note that spaces that are isomorphic are not necessarily equal. One can be a dual space, and the other a normal space, or one can be an instance of ProductSpace, while the other is an ElementarySpace. There will exist (infinitely) many isomorphisms between the corresponding spaces, but in general none of those will be canonical.

    There are also a number of convenience functions to create isomorphic spaces. The function fuse(V1, V2, ...) or fuse(V1 ⊗ V2 ⊗ ...) returns an elementary space that is isomorphic to V1 ⊗ V2 ⊗ .... The function flip(V::ElementarySpace) returns a space that is isomorphic to V but has isdual(flip(V)) == isdual(V'), i.e. if V is a normal space than flip(V) is a dual space. flip(V) is different from dual(V) in the case of GradedSpace. It is useful to flip a tensor index from a ket to a bra (or vice versa), by contracting that index with a unitary map from V1 to flip(V1). We refer to Index operations for further information. Some examples:

    julia> ℝ^3 ≾ ℝ^5true
    julia> ℂ^3 ≾ (ℂ^5)'true
    julia> (ℂ^5) ≅ (ℂ^5)'true
    julia> fuse(ℝ^5, ℝ^3)ℝ^15
    julia> fuse(ℂ^3, (ℂ^5)' ⊗ ℂ^2)ℂ^30
    julia> fuse(ℂ^3, (ℂ^5)') ⊗ ℂ^2 ≅ fuse(ℂ^3, (ℂ^5)', ℂ^2) ≅ ℂ^3 ⊗ (ℂ^5)' ⊗ ℂ^2true
    julia> flip(ℂ^4)(ℂ^4)'
    julia> flip(ℂ^4) ≅ ℂ^4true
    julia> flip(ℂ^4) == ℂ^4false

    We also define the direct sum V1 and V2 as V1 ⊕ V2, where is obtained by typing \oplus+TAB. This is possible only if isdual(V1) == isdual(V2). With a little pun on Julia Base, oneunit applied to an elementary space (in the value or type domain) returns the one-dimensional space, which is isomorphic to the scalar field of the space itself. Some examples illustrate this better

    julia> ℝ^5 ⊕ ℝ^3ℝ^8
    julia> ℂ^5 ⊕ ℂ^3ℂ^8
    julia> ℂ^5 ⊕ (ℂ^3)'ERROR: SpaceMismatch("Direct sum of a vector space and its dual does not exist")
    julia> oneunit(ℝ^3)ℝ^1
    julia> ℂ^5 ⊕ oneunit(ComplexSpace)ℂ^6
    julia> oneunit((ℂ^3)')ℂ^1
    julia> (ℂ^5) ⊕ oneunit((ℂ^5))ℂ^6
    julia> (ℂ^5)' ⊕ oneunit((ℂ^5)')ERROR: SpaceMismatch("Direct sum of a vector space and its dual does not exist")

    Finally, while spaces have a partial order, there is no unique infimum or supremum of a two or more spaces. However, if V1 and V2 are two ElementarySpace instances with isdual(V1) == isdual(V2), then we can define a unique infimum V::ElementarySpace with the same value of isdual that satisfies V ≾ V1 and V ≾ V2, as well as a unique supremum W::ElementarySpace with the same value of isdual that satisfies W ≿ V1 and W ≿ V2. For CartesianSpace and ComplexSpace, this simply amounts to the space with minimal or maximal dimension, i.e.

    julia> infimum(ℝ^5, ℝ^3)ℝ^3
    julia> supremum(ℂ^5, ℂ^3)ℂ^5
    julia> supremum(ℂ^5, (ℂ^3)')ERROR: SpaceMismatch("Supremum of space and dual space does not exist")

    The names infimum and supremum are especially suited in the case of GradedSpace, as the infimum of two spaces might be different from either of those two spaces, and similar for the supremum.

    +≻(V1::VectorSpace, V2::VectorSpace) = V1 ≿ V2 && !(V1 ≾ V2)

    However, as we expect these to be less commonly used, no ASCII alternative is provided.

    In the context of InnerProductStyle(V) <: EuclideanProduct, V1 ≾ V2 implies that there exists isometries $W:V1 → V2$ such that $W^† ∘ W = \mathrm{id}_{V1}$, while V1 ≅ V2 implies that there exist unitaries $U:V1→V2$ such that $U^† ∘ U = \mathrm{id}_{V1}$ and $U ∘ U^† = \mathrm{id}_{V2}$.

    Note that spaces that are isomorphic are not necessarily equal. One can be a dual space, and the other a normal space, or one can be an instance of ProductSpace, while the other is an ElementarySpace. There will exist (infinitely) many isomorphisms between the corresponding spaces, but in general none of those will be canonical.

    There are also a number of convenience functions to create isomorphic spaces. The function fuse(V1, V2, ...) or fuse(V1 ⊗ V2 ⊗ ...) returns an elementary space that is isomorphic to V1 ⊗ V2 ⊗ .... The function flip(V::ElementarySpace) returns a space that is isomorphic to V but has isdual(flip(V)) == isdual(V'), i.e. if V is a normal space than flip(V) is a dual space. flip(V) is different from dual(V) in the case of GradedSpace. It is useful to flip a tensor index from a ket to a bra (or vice versa), by contracting that index with a unitary map from V1 to flip(V1). We refer to Index operations for further information. Some examples:

    julia> ℝ^3 ≾ ℝ^5true
    julia> ℂ^3 ≾ (ℂ^5)'true
    julia> (ℂ^5) ≅ (ℂ^5)'true
    julia> fuse(ℝ^5, ℝ^3)ℝ^15
    julia> fuse(ℂ^3, (ℂ^5)' ⊗ ℂ^2)ℂ^30
    julia> fuse(ℂ^3, (ℂ^5)') ⊗ ℂ^2 ≅ fuse(ℂ^3, (ℂ^5)', ℂ^2) ≅ ℂ^3 ⊗ (ℂ^5)' ⊗ ℂ^2true
    julia> flip(ℂ^4)(ℂ^4)'
    julia> flip(ℂ^4) ≅ ℂ^4true
    julia> flip(ℂ^4) == ℂ^4false

    We also define the direct sum V1 and V2 as V1 ⊕ V2, where is obtained by typing \oplus+TAB. This is possible only if isdual(V1) == isdual(V2). With a little pun on Julia Base, oneunit applied to an elementary space (in the value or type domain) returns the one-dimensional space, which is isomorphic to the scalar field of the space itself. Some examples illustrate this better

    julia> ℝ^5 ⊕ ℝ^3ℝ^8
    julia> ℂ^5 ⊕ ℂ^3ℂ^8
    julia> ℂ^5 ⊕ (ℂ^3)'ERROR: SpaceMismatch("Direct sum of a vector space and its dual does not exist")
    julia> oneunit(ℝ^3)ℝ^1
    julia> ℂ^5 ⊕ oneunit(ComplexSpace)ℂ^6
    julia> oneunit((ℂ^3)')ℂ^1
    julia> (ℂ^5) ⊕ oneunit((ℂ^5))ℂ^6
    julia> (ℂ^5)' ⊕ oneunit((ℂ^5)')ERROR: SpaceMismatch("Direct sum of a vector space and its dual does not exist")

    Finally, while spaces have a partial order, there is no unique infimum or supremum of a two or more spaces. However, if V1 and V2 are two ElementarySpace instances with isdual(V1) == isdual(V2), then we can define a unique infimum V::ElementarySpace with the same value of isdual that satisfies V ≾ V1 and V ≾ V2, as well as a unique supremum W::ElementarySpace with the same value of isdual that satisfies W ≿ V1 and W ≿ V2. For CartesianSpace and ComplexSpace, this simply amounts to the space with minimal or maximal dimension, i.e.

    julia> infimum(ℝ^5, ℝ^3)ℝ^3
    julia> supremum(ℂ^5, ℂ^3)ℂ^5
    julia> supremum(ℂ^5, (ℂ^3)')ERROR: SpaceMismatch("Supremum of space and dual space does not exist")

    The names infimum and supremum are especially suited in the case of GradedSpace, as the infimum of two spaces might be different from either of those two spaces, and similar for the supremum.

    diff --git a/dev/man/tensors/index.html b/dev/man/tensors/index.html index 161aa139..70608293 100644 --- a/dev/man/tensors/index.html +++ b/dev/man/tensors/index.html @@ -4,45 +4,38 @@ TensorMap(undef, codomain, domain) TensorMap(undef, eltype::Type{<:Number}, codomain, domain)

    Here, in the first form, f can be any function or object that is called with an argument of type Dims{2} = Tuple{Int,Int} and is such that f((m,n)) creates a DenseMatrix instance with size(f(m,n)) == (m,n). In the second form, f is called as f(eltype,(m,n)). Possibilities for f are randn and rand from Julia Base. TensorKit.jl provides randnormal and randuniform as an synonym for randn and rand, as well as the new function randisometry, alternatively called randhaar, that creates a random isometric m × n matrix w satisfying w'*w ≈ I distributed according to the Haar measure (this requires m>= n). The third and fourth calling syntax use the UndefInitializer from Julia Base and generates a TensorMap with unitialized data, which could thus contain NaNs.

    In all of these constructors, the last two arguments can be replaced by domain→codomain or codomain←domain, where the arrows are obtained as \rightarrow+TAB and \leftarrow+TAB and create a HomSpace as explained in the section on Spaces of morphisms. Some examples are perhaps in order

    julia> t1 = TensorMap(randnormal, ℂ^2 ⊗ ℂ^3, ℂ^2)TensorMap((ℂ^2 ⊗ ℂ^3) ← ℂ^2):
     [:, :, 1] =
    - -0.491520698273336   0.09517588009872073  -0.762475182152889
    - -0.3699344105401677  0.6609173543148776   -1.8971646115007765
    +  1.5247240268727131  -0.9185165325735327  -0.22038794995495112
    + -1.270736467627332    1.6146866371170638   0.13634690928370855
     
     [:, :, 2] =
    - 0.16095701393434797  0.6542371379562142  -1.2016693655314394
    - 0.3262046892318915   1.1015268982157105   0.3992775502140272
    julia> t2 = TensorMap(randisometry, Float32, ℂ^2 ⊗ ℂ^3 ← ℂ^2)TensorMap((ℂ^2 ⊗ ℂ^3) ← ℂ^2): + -1.0494192526650838 0.37845509408843325 0.1632501410035993 + -0.3165495492222638 0.6616177066817684 -1.1817667337144855
    julia> t2 = TensorMap(randisometry, Float32, ℂ^2 ⊗ ℂ^3 ← ℂ^2)ERROR: UndefVarError: `_leftorth!` not defined
    julia> t3 = TensorMap(undef, ℂ^2 → ℂ^2 ⊗ ℂ^3)TensorMap((ℂ^2 ⊗ ℂ^3) ← ℂ^2): [:, :, 1] = - 0.3146466f0 0.22934723f0 0.1298909f0 - -0.45120952f0 -0.68306684f0 -0.40169066f0 + 2.75859452845e-313 2.1219958004e-314 2.737374570464e-312 + 4.03179200323e-313 5.0927898995e-313 2.864694318455e-312 [:, :, 2] = - -0.11042473f0 0.66516644f0 -0.7186733f0 - -0.113025546f0 0.124574795f0 -0.023984807f0
    julia> t3 = TensorMap(undef, ℂ^2 → ℂ^2 ⊗ ℂ^3)TensorMap((ℂ^2 ⊗ ℂ^3) ← ℂ^2): + 1.0e-323 0.0 0.0 + 0.0 0.0 0.0
    julia> domain(t1) == domain(t2) == domain(t3)ERROR: UndefVarError: `t2` not defined
    julia> codomain(t1) == codomain(t2) == codomain(t3)ERROR: UndefVarError: `t2` not defined
    julia> disp(x) = show(IOContext(Core.stdout, :compact=>false), "text/plain", trunc.(x; digits = 3));
    julia> t1[] |> disp2×3×2 StridedViews.StridedView{Float64, 3, Array{Float64, 3}, typeof(identity)}: [:, :, 1] = - 6.9135516738361e-310 6.91357760811617e-310 6.91355167384086e-310 - 6.9135516738377e-310 6.9135516738393e-310 6.91355167384245e-310 + 1.524 -0.918 -0.22 + -1.27 1.614 0.136 [:, :, 2] = - 6.91355167384403e-310 6.9135516738472e-310 6.91355167385035e-310 - 6.9135516738456e-310 6.91357760811617e-310 6.91355167385193e-310
    julia> domain(t1) == domain(t2) == domain(t3)true
    julia> codomain(t1) == codomain(t2) == codomain(t3)true
    julia> disp(x) = show(IOContext(Core.stdout, :compact=>false), "text/plain", trunc.(x; digits = 3));
    julia> t1[] |> disp2×3×2 StridedViews.StridedView{Float64, 3, Array{Float64, 3}, typeof(identity)}: -[:, :, 1] = - -0.491 0.095 -0.762 - -0.369 0.66 -1.897 - -[:, :, 2] = - 0.16 0.654 -1.201 - 0.326 1.101 0.399
    julia> block(t1, Trivial()) |> disp6×2 Array{Float64, 2}: - -0.491 0.16 - -0.369 0.326 - 0.095 0.654 - 0.66 1.101 - -0.762 -1.201 - -1.897 0.399
    julia> reshape(t1[], dim(codomain(t1)), dim(domain(t1))) |> disp6×2 Array{Float64, 2}: - -0.491 0.16 - -0.369 0.326 - 0.095 0.654 - 0.66 1.101 - -0.762 -1.201 - -1.897 0.399

    Finally, all constructors can also be replaced by Tensor(..., codomain), in which case the domain is assumed to be the empty ProductSpace{S,0}(), which can easily be obtained as one(codomain). Indeed, the empty product space is the unit object of the monoidal category, equivalent to the field of scalars 𝕜, and thus the multiplicative identity (especially since * also acts as tensor product on vector spaces).

    The matrices created by f are the matrices $B_c$ discussed above, i.e. those returned by block(t, c). Only numerical matrices of type DenseMatrix are accepted, which in practice just means Julia's intrinsic Matrix{T} for some T<:Number. In the future, we will add support for CuMatrix from CuArrays.jl to harness GPU computing power, and maybe SharedArray from the Julia's SharedArrays standard library.

    Support for static or sparse data is currently unavailable, and if it would be implemented, it would lead to new subtypes of AbstractTensorMap which are distinct from TensorMap. Future implementations of e.g. SparseTensorMap or StaticTensorMap could be useful. Furthermore, there could be specific implementations for tensors whose blocks are Diagonal.

    Tensor maps from existing data

    To create a TensorMap with existing data, one can use the aforementioned form but with the function f replaced with the actual data, i.e. TensorMap(data, codomain, domain) or any of its equivalents.

    Here, data can be of two types. It can be a dictionary (any Associative subtype) which has blocksectors c of type sectortype(codomain) as keys, and the corresponding matrix blocks as value, i.e. data[c] is some DenseMatrix of size (blockdim(codomain, c), blockdim(domain, c)). This is the form of how the data is stored within the TensorMap objects.

    For those space types for which a TensorMap can be converted to a plain multidimensional array, the data can also be a general DenseArray, either of rank N₁+N₂ and with matching size (dims(codomain)..., dims(domain)...), or just as a DenseMatrix with size (dim(codomain), dim(domain)). This is true in particular if the sector type is Trivial, e.g. for CartesianSpace or ComplexSpace. Then the data array is just reshaped into matrix form and referred to as such in the resulting TensorMap instance. When spacetype is GradedSpace, the TensorMap constructor will try to reconstruct the tensor data such that the resulting tensor t satisfies data == convert(Array, t). This might not be possible, if the data does not respect the symmetry structure. Let's sketch this with a simple example

    julia> data = zeros(2,2,2,2)2×2×2×2 Array{Float64, 4}:
    + -1.049  0.378   0.163
    + -0.316  0.661  -1.181
    julia> block(t1, Trivial()) |> disp6×2 Array{Float64, 2}: + 1.524 -1.049 + -1.27 -0.316 + -0.918 0.378 + 1.614 0.661 + -0.22 0.163 + 0.136 -1.181
    julia> reshape(t1[], dim(codomain(t1)), dim(domain(t1))) |> disp6×2 Array{Float64, 2}: + 1.524 -1.049 + -1.27 -0.316 + -0.918 0.378 + 1.614 0.661 + -0.22 0.163 + 0.136 -1.181

    Finally, all constructors can also be replaced by Tensor(..., codomain), in which case the domain is assumed to be the empty ProductSpace{S,0}(), which can easily be obtained as one(codomain). Indeed, the empty product space is the unit object of the monoidal category, equivalent to the field of scalars 𝕜, and thus the multiplicative identity (especially since * also acts as tensor product on vector spaces).

    The matrices created by f are the matrices $B_c$ discussed above, i.e. those returned by block(t, c). Only numerical matrices of type DenseMatrix are accepted, which in practice just means Julia's intrinsic Matrix{T} for some T<:Number. In the future, we will add support for CuMatrix from CuArrays.jl to harness GPU computing power, and maybe SharedArray from the Julia's SharedArrays standard library.

    Support for static or sparse data is currently unavailable, and if it would be implemented, it would lead to new subtypes of AbstractTensorMap which are distinct from TensorMap. Future implementations of e.g. SparseTensorMap or StaticTensorMap could be useful. Furthermore, there could be specific implementations for tensors whose blocks are Diagonal.

    Tensor maps from existing data

    To create a TensorMap with existing data, one can use the aforementioned form but with the function f replaced with the actual data, i.e. TensorMap(data, codomain, domain) or any of its equivalents.

    Here, data can be of two types. It can be a dictionary (any Associative subtype) which has blocksectors c of type sectortype(codomain) as keys, and the corresponding matrix blocks as value, i.e. data[c] is some DenseMatrix of size (blockdim(codomain, c), blockdim(domain, c)). This is the form of how the data is stored within the TensorMap objects.

    For those space types for which a TensorMap can be converted to a plain multidimensional array, the data can also be a general DenseArray, either of rank N₁+N₂ and with matching size (dims(codomain)..., dims(domain)...), or just as a DenseMatrix with size (dim(codomain), dim(domain)). This is true in particular if the sector type is Trivial, e.g. for CartesianSpace or ComplexSpace. Then the data array is just reshaped into matrix form and referred to as such in the resulting TensorMap instance. When spacetype is GradedSpace, the TensorMap constructor will try to reconstruct the tensor data such that the resulting tensor t satisfies data == convert(Array, t). This might not be possible, if the data does not respect the symmetry structure. Let's sketch this with a simple example

    julia> data = zeros(2,2,2,2)2×2×2×2 Array{Float64, 4}:
     [:, :, 1, 1] =
      0.0  0.0
      0.0  0.0
    @@ -115,192 +108,192 @@
      1.0

    Hence, we recognize that the Heisenberg interaction has eigenvalue $-1$ in the coupled spin zero sector (SUIrrep(0)), and eigenvalue $+1$ in the coupled spin 1 sector (SU2Irrep(1)). Using Irrep[U₁] instead, we observe that both coupled charge U1Irrep(+1) and U1Irrep(-1) have eigenvalue $+1$. The coupled charge U1Irrep(0) sector is two-dimensional, and has an eigenvalue $+1$ and an eigenvalue $-1$.

    To construct the proper data in more complicated cases, one has to know where to find each sector in the range 1:dim(V) of every index i with associated space V, as well as the internal structure of the representation space when the corresponding sector c has dim(c)>1, i.e. in the case of FusionStyle(c) isa MultipleFusion. Currently, the only non- abelian sectors are Irrep[SU₂] and Irrep[CU₁], for which the internal structure is the natural one.

    There are some tools available to facilate finding the proper range of sector c in space V, namely axes(V, c). This also works on a ProductSpace, with a tuple of sectors. An example

    julia> V = SU2Space(0=>3, 1=>2, 2=>1)Rep[SU₂](0=>3, 1=>2, 2=>1)
    julia> P = V ⊗ V ⊗ V(Rep[SU₂](0=>3, 1=>2, 2=>1) ⊗ Rep[SU₂](0=>3, 1=>2, 2=>1) ⊗ Rep[SU₂](0=>3, 1=>2, 2=>1))
    julia> axes(P, (SU2Irrep(1), SU2Irrep(0), SU2Irrep(2)))(4:9, 1:3, 10:14)

    Note that the length of the range is the degeneracy dimension of that sector, times the dimension of the internal representation space, i.e. the quantum dimension of that sector.

    Constructing similar tensors

    A third way to construct a TensorMap instance is to use Base.similar, i.e.

    similar(t [, T::Type{<:Number}, codomain, domain])

    where T is a possibly different eltype for the tensor data, and codomain and domain optionally define a new codomain and domain for the resulting tensor. By default, these values just take the value from the input tensor t. The result will be a new TensorMap instance, with undef data, but whose data is stored in the same subtype of DenseMatrix (e.g. Matrix or CuMatrix or ...) as t. In particular, this uses the methods storagetype(t) and TensorKit.similarstoragetype(t, T).

    Special purpose constructors

    Finally, there are methods zero, one, id, isomorphism, unitary and isometry to create specific new tensors. Tensor maps behave as vectors and can be added (if they have the same domain and codomain); zero(t) is the additive identity, i.e. a TensorMap instance where all entries are zero. For a t::TensorMap with domain(t) == codomain(t), i.e. an endomorphism, one(t) creates the identity tensor, i.e. the identity under composition. As discussed in the section on linear algebra operations, we denote composition of tensor maps with the mutliplication operator *, such that one(t) is the multiplicative identity. Similarly, it can be created as id(V) with V the relevant vector space, e.g. one(t) == id(domain(t)). The identity tensor is currently represented with dense data, and one can use id(A::Type{<:DenseMatrix}, V) to specify the type of DenseMatrix (and its eltype), e.g. A = Matrix{Float64}. Finally, it often occurs that we want to construct a specific isomorphism between two spaces that are isomorphic but not equal, and for which there is no canonical choice. Hereto, one can use the method u = isomorphism([A::Type{<:DenseMatrix}, ] codomain, domain), which will explicitly check that the domain and codomain are isomorphic, and return an error otherwise. Again, an optional first argument can be given to specify the specific type of DenseMatrix that is currently used to store the rather trivial data of this tensor. If InnerProductStyle(u) <: EuclideanProduct, the same result can be obtained with the method u = unitary([A::Type{<:DenseMatrix}, ] codomain, domain). Note that reversing the domain and codomain yields the inverse morphism, which in the case of EuclideanProduct coincides with the adjoint morphism, i.e. isomorphism(A, domain, codomain) == adjoint(u) == inv(u), where inv and adjoint will be further discussed below. Finally, if two spaces V1 and V2 are such that V2 can be embedded in V1, i.e. there exists an inclusion with a left inverse, and furthermore they represent tensor products of some ElementarySpace with EuclideanProduct, the function w = isometry([A::Type{<:DenseMatrix}, ], V1, V2) creates one specific isometric embedding, such that adjoint(w) * w == id(V2) and w * adjoint(w) is some hermitian idempotent (a.k.a. orthogonal projector) acting on V1. An error will be thrown if such a map cannot be constructed for the given domain and codomain.

    Let's conclude this section with some examples with GradedSpace.

    julia> V1 = ℤ₂Space(0=>3,1=>2)Rep[ℤ₂](0=>3, 1=>2)
    julia> V2 = ℤ₂Space(0=>2,1=>1)Rep[ℤ₂](0=>2, 1=>1)
    julia> # First a `TensorMap{ℤ₂Space, 1, 1}` m = TensorMap(randn, V1, V2)TensorMap(Rep[ℤ₂](0=>3, 1=>2) ← Rep[ℤ₂](0=>2, 1=>1)): * Data for sector (Irrep[ℤ₂](0),) ← (Irrep[ℤ₂](0),): - -0.8563394528396604 0.384290884918033 - -0.9099941496423876 -0.10145545439480415 - -0.0454643618048501 1.5158757743337907 + 0.47785425663908704 -1.4200099855428314 + 0.19327121410298997 0.053670569572136125 + 1.2695216966733702 -1.2537718513704916 * Data for sector (Irrep[ℤ₂](1),) ← (Irrep[ℤ₂](1),): - 0.02391081480052989 - -0.4077602758946229
    julia> convert(Array, m) |> disp5×3 Array{Float64, 2}: - -0.856 0.384 0.0 - -0.909 -0.101 0.0 - -0.045 1.515 0.0 - 0.0 0.0 0.023 - 0.0 0.0 -0.407
    julia> # compare with: + -1.096919341842966 + 1.3674106509754853
    julia> convert(Array, m) |> disp5×3 Array{Float64, 2}: + 0.477 -1.42 0.0 + 0.193 0.053 0.0 + 1.269 -1.253 0.0 + 0.0 0.0 -1.096 + 0.0 0.0 1.367
    julia> # compare with: block(m, Irrep[ℤ₂](0)) |> disp3×2 Array{Float64, 2}: - -0.856 0.384 - -0.909 -0.101 - -0.045 1.515
    julia> block(m, Irrep[ℤ₂](1)) |> disp2×1 Array{Float64, 2}: - 0.023 - -0.407
    julia> # Now a `TensorMap{ℤ₂Space, 2, 2}` + 0.477 -1.42 + 0.193 0.053 + 1.269 -1.253
    julia> block(m, Irrep[ℤ₂](1)) |> disp2×1 Array{Float64, 2}: + -1.096 + 1.367
    julia> # Now a `TensorMap{ℤ₂Space, 2, 2}` t = TensorMap(randn, V1 ⊗ V1, V2 ⊗ V2')TensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>3, 1=>2)) ← (Rep[ℤ₂](0=>2, 1=>1) ⊗ Rep[ℤ₂](0=>2, 1=>1)')): * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](0)): [:, :, 1, 1] = - 0.7429415405254858 0.5507795877615677 -0.9382729451463792 - -0.029324170078592178 -0.3246733498567814 0.41612149315448155 - 0.2654307808652076 0.35172726110251634 0.3101209643231978 + 1.1083546522388328 0.9645936928075823 0.4688214975365843 + 0.0513950027833962 -0.9463219458455515 -0.8733045943229443 + -0.34249311245904845 -0.5684676318225965 0.9766691784842794 [:, :, 2, 1] = - 0.3514153670426092 0.4791025779057673 0.9219460549768435 - -0.8608271233879453 2.6565559786120687 1.2262529004278073 - -1.5219781745599381 -1.408353080661672 0.7564062134018735 + 0.7839846210088314 -0.4422740276919987 -0.3936689542193575 + 0.2699981435588199 -0.7671989143170143 -0.4602961326946507 + 0.6708252072228028 0.1734909593644019 0.7346161016368267 [:, :, 1, 2] = - -1.5573160968193762 2.071697552023246 1.4736798746317297 - -0.2954140679783098 1.0188262510453656 -0.3405485491393891 - -0.19632707376820957 0.28362764198751816 -1.0327626192425658 + 0.6231627261125112 -0.3991885208270406 -0.9791199202333164 + -0.4634695738493423 0.01088123868881053 0.29906575622620296 + 0.05905092123323947 -0.6211542580706039 -0.22204394275141529 [:, :, 2, 2] = - -0.04375409616092905 -0.8679328004616798 -1.8288264239760341 - -0.03466928936766076 1.5851302728059609 1.0774371548683181 - -1.0727862668188481 0.12564638101148426 -1.6623497418871898 + -0.3286364738095289 0.3322549082840089 0.4976823137657312 + -0.2407978640929069 -0.4174912223957381 0.6876447142779137 + -1.5548157687110473 1.16418323477959 -0.28170695890515973 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](0)): [:, :, 1, 1] = - -0.7246015411290976 -0.7723948813087984 - -0.978125109987975 -1.6061830541988917 + 0.49796950451494265 -0.41551516606111316 + 0.0009838099871122472 -0.5541849086562921 [:, :, 2, 1] = - -1.101989628736328 1.0730570519614713 - -0.09771151069326181 -0.6086680906449499 + 1.4590841833204773 -0.002264518478690231 + -0.6953516201500334 -0.4542126874173308 [:, :, 1, 2] = - -0.8686962413707943 -0.5057980538505777 - 0.21353664999557417 -1.2922894917364234 + 0.6167877125657005 -0.5621057370713477 + 0.1265425066226539 0.9675919134036324 [:, :, 2, 2] = - -1.7803561467667883 0.6539077223006167 - 2.0154714658291177 -1.8708203966168602 + 1.798801977510327 -0.1152576476767119 + 0.706239468990326 0.7761632474336987 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](1)): [:, :, 1, 1] = - 0.6789066505055149 0.28272604287407327 0.8652978023075938 - -0.3096481614736897 0.05048753307045538 -0.10545487452335392 - -0.3999147631191598 -1.1247504905828913 0.6285597571414818 + 0.32582916583349975 0.4800428304364218 -0.6663241943046653 + 0.8789506287342465 0.47176321237007435 0.4804834532553622 + 0.16240787460840714 0.07692169380586183 -0.512272448722823 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](1)): [:, :, 1, 1] = - 0.13181175169606257 -0.25633539618447226 - 0.5040736822415827 0.8875642185923674 + -0.9001337770068216 0.83518828117775 + 0.4151792926684182 -0.14217471046616104 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](1)): [:, :, 1, 1] = - -0.23625756361060518 1.4838775930883723 1.4732955410120723 - -1.961816354429739 0.22768277858948585 -0.07911113864476405 + -0.31981948470716653 -1.3285686283795777 -0.7291402458263933 + -0.11458324916145991 -0.05579157669725461 -2.1417430908110604 [:, :, 2, 1] = - 0.6717008950659635 0.019605917749061938 -1.5260955639199254 - -1.7531826051067332 0.17507278186648992 0.7644522514690727 + 0.31081416401615475 2.319584153795229 1.094942112823673 + 0.3916111081341926 -1.059876340537205 -0.349448682397556 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](1)): [:, :, 1, 1] = - -0.15344959513160236 -1.457969012542062 - -0.2704931682659092 -0.8714174645219185 - -0.7209609578900229 0.9473039520110696 + 0.14603323505234406 -0.4155704353202816 + 0.7826083513531809 0.6000999631272578 + 0.3030009337519121 1.6172109192048834 [:, :, 2, 1] = - 0.8666605194362084 -0.4757327500572567 - -0.9567317656575793 0.9143012849515912 - -0.8564605469436541 0.8559783627533434 + -0.48319716069832785 -1.098606484442863 + -0.692060744745361 0.12003832324002896 + -0.09622766242381225 -0.28450937274100807 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](0)): [:, :, 1, 1] = - 1.6664063851256954 -0.4516338132859887 -0.10320725418062385 - -1.042006228061675 -0.8475515694378462 0.926886643381141 + 0.22168921079495593 -0.5973954147275384 -0.24812841115803086 + 0.5962934355939906 -0.16700684718850414 -0.7064797641542205 [:, :, 1, 2] = - 0.6228392997532234 0.8224598377959966 -0.34930736991305067 - -0.9628701802234364 -0.1572229709593226 -0.2974309562984329 + 1.8623322850331767 0.6913827604452818 1.4092667115609059 + -0.11233997414487934 -0.13505456448422687 0.734922490415507 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](0)): [:, :, 1, 1] = - -0.7672686724757068 -0.46423073980921986 - 1.0368529408086322 0.4287064464911203 - -0.652517390459797 0.00236768993277952 + 1.3383090786325285 0.7085684611053271 + 0.6184390249127638 -0.18001135301756582 + -1.7255262536964093 -0.45478093743943104 [:, :, 1, 2] = - -0.971332119524957 -1.2532194745310357 - -0.3034527029973646 -0.5060554427621455 - -1.5286581269576898 -1.6770873145761107
    julia> (array = convert(Array, t)) |> disp5×5×3×3 Array{Float64, 4}: + 0.7915415548570354 0.2741072177572122 + 0.3464690378586438 -1.261303531183468 + -0.14303129457783212 0.6236987712499479
    julia> (array = convert(Array, t)) |> disp5×5×3×3 Array{Float64, 4}: [:, :, 1, 1] = - 0.742 0.55 -0.938 0.0 0.0 - -0.029 -0.324 0.416 0.0 0.0 - 0.265 0.351 0.31 0.0 0.0 - 0.0 0.0 0.0 -0.724 -0.772 - 0.0 0.0 0.0 -0.978 -1.606 + 1.108 0.964 0.468 0.0 0.0 + 0.051 -0.946 -0.873 0.0 0.0 + -0.342 -0.568 0.976 0.0 0.0 + 0.0 0.0 0.0 0.497 -0.415 + 0.0 0.0 0.0 0.0 -0.554 [:, :, 2, 1] = - 0.351 0.479 0.921 0.0 0.0 - -0.86 2.656 1.226 0.0 0.0 - -1.521 -1.408 0.756 0.0 0.0 - 0.0 0.0 0.0 -1.101 1.073 - 0.0 0.0 0.0 -0.097 -0.608 + 0.783 -0.442 -0.393 0.0 0.0 + 0.269 -0.767 -0.46 0.0 0.0 + 0.67 0.173 0.734 0.0 0.0 + 0.0 0.0 0.0 1.459 -0.002 + 0.0 0.0 0.0 -0.695 -0.454 [:, :, 3, 1] = - 0.0 0.0 0.0 -0.767 -0.464 - 0.0 0.0 0.0 1.036 0.428 - 0.0 0.0 0.0 -0.652 0.002 - 1.666 -0.451 -0.103 0.0 0.0 - -1.042 -0.847 0.926 0.0 0.0 + 0.0 0.0 0.0 1.338 0.708 + 0.0 0.0 0.0 0.618 -0.18 + 0.0 0.0 0.0 -1.725 -0.454 + 0.221 -0.597 -0.248 0.0 0.0 + 0.596 -0.167 -0.706 0.0 0.0 [:, :, 1, 2] = - -1.557 2.071 1.473 0.0 0.0 - -0.295 1.018 -0.34 0.0 0.0 - -0.196 0.283 -1.032 0.0 0.0 - 0.0 0.0 0.0 -0.868 -0.505 - 0.0 0.0 0.0 0.213 -1.292 + 0.623 -0.399 -0.979 0.0 0.0 + -0.463 0.01 0.299 0.0 0.0 + 0.059 -0.621 -0.222 0.0 0.0 + 0.0 0.0 0.0 0.616 -0.562 + 0.0 0.0 0.0 0.126 0.967 [:, :, 2, 2] = - -0.043 -0.867 -1.828 0.0 0.0 - -0.034 1.585 1.077 0.0 0.0 - -1.072 0.125 -1.662 0.0 0.0 - 0.0 0.0 0.0 -1.78 0.653 - 0.0 0.0 0.0 2.015 -1.87 + -0.328 0.332 0.497 0.0 0.0 + -0.24 -0.417 0.687 0.0 0.0 + -1.554 1.164 -0.281 0.0 0.0 + 0.0 0.0 0.0 1.798 -0.115 + 0.0 0.0 0.0 0.706 0.776 [:, :, 3, 2] = - 0.0 0.0 0.0 -0.971 -1.253 - 0.0 0.0 0.0 -0.303 -0.506 - 0.0 0.0 0.0 -1.528 -1.677 - 0.622 0.822 -0.349 0.0 0.0 - -0.962 -0.157 -0.297 0.0 0.0 + 0.0 0.0 0.0 0.791 0.274 + 0.0 0.0 0.0 0.346 -1.261 + 0.0 0.0 0.0 -0.143 0.623 + 1.862 0.691 1.409 0.0 0.0 + -0.112 -0.135 0.734 0.0 0.0 [:, :, 1, 3] = - 0.0 0.0 0.0 -0.153 -1.457 - 0.0 0.0 0.0 -0.27 -0.871 - 0.0 0.0 0.0 -0.72 0.947 - -0.236 1.483 1.473 0.0 0.0 - -1.961 0.227 -0.079 0.0 0.0 + 0.0 0.0 0.0 0.146 -0.415 + 0.0 0.0 0.0 0.782 0.6 + 0.0 0.0 0.0 0.303 1.617 + -0.319 -1.328 -0.729 0.0 0.0 + -0.114 -0.055 -2.141 0.0 0.0 [:, :, 2, 3] = - 0.0 0.0 0.0 0.866 -0.475 - 0.0 0.0 0.0 -0.956 0.914 - 0.0 0.0 0.0 -0.856 0.855 - 0.671 0.019 -1.526 0.0 0.0 - -1.753 0.175 0.764 0.0 0.0 + 0.0 0.0 0.0 -0.483 -1.098 + 0.0 0.0 0.0 -0.692 0.12 + 0.0 0.0 0.0 -0.096 -0.284 + 0.31 2.319 1.094 0.0 0.0 + 0.391 -1.059 -0.349 0.0 0.0 [:, :, 3, 3] = - 0.678 0.282 0.865 0.0 0.0 - -0.309 0.05 -0.105 0.0 0.0 - -0.399 -1.124 0.628 0.0 0.0 - 0.0 0.0 0.0 0.131 -0.256 - 0.0 0.0 0.0 0.504 0.887
    julia> d1 = dim(codomain(t))25
    julia> d2 = dim(domain(t))9
    julia> (matrix = reshape(array, d1, d2)) |> disp25×9 Array{Float64, 2}: - 0.742 0.351 0.0 -1.557 -0.043 0.0 0.0 0.0 0.678 - -0.029 -0.86 0.0 -0.295 -0.034 0.0 0.0 0.0 -0.309 - 0.265 -1.521 0.0 -0.196 -1.072 0.0 0.0 0.0 -0.399 - 0.0 0.0 1.666 0.0 0.0 0.622 -0.236 0.671 0.0 - 0.0 0.0 -1.042 0.0 0.0 -0.962 -1.961 -1.753 0.0 - 0.55 0.479 0.0 2.071 -0.867 0.0 0.0 0.0 0.282 - -0.324 2.656 0.0 1.018 1.585 0.0 0.0 0.0 0.05 - 0.351 -1.408 0.0 0.283 0.125 0.0 0.0 0.0 -1.124 - 0.0 0.0 -0.451 0.0 0.0 0.822 1.483 0.019 0.0 - 0.0 0.0 -0.847 0.0 0.0 -0.157 0.227 0.175 0.0 - -0.938 0.921 0.0 1.473 -1.828 0.0 0.0 0.0 0.865 - 0.416 1.226 0.0 -0.34 1.077 0.0 0.0 0.0 -0.105 - 0.31 0.756 0.0 -1.032 -1.662 0.0 0.0 0.0 0.628 - 0.0 0.0 -0.103 0.0 0.0 -0.349 1.473 -1.526 0.0 - 0.0 0.0 0.926 0.0 0.0 -0.297 -0.079 0.764 0.0 - 0.0 0.0 -0.767 0.0 0.0 -0.971 -0.153 0.866 0.0 - 0.0 0.0 1.036 0.0 0.0 -0.303 -0.27 -0.956 0.0 - 0.0 0.0 -0.652 0.0 0.0 -1.528 -0.72 -0.856 0.0 - -0.724 -1.101 0.0 -0.868 -1.78 0.0 0.0 0.0 0.131 - -0.978 -0.097 0.0 0.213 2.015 0.0 0.0 0.0 0.504 - 0.0 0.0 -0.464 0.0 0.0 -1.253 -1.457 -0.475 0.0 - 0.0 0.0 0.428 0.0 0.0 -0.506 -0.871 0.914 0.0 - 0.0 0.0 0.002 0.0 0.0 -1.677 0.947 0.855 0.0 - -0.772 1.073 0.0 -0.505 0.653 0.0 0.0 0.0 -0.256 - -1.606 -0.608 0.0 -1.292 -1.87 0.0 0.0 0.0 0.887
    julia> (u = reshape(convert(Array, unitary(codomain(t), fuse(codomain(t)))), d1, d1)) |> disp25×25 Array{Float64, 2}: + 0.325 0.48 -0.666 0.0 0.0 + 0.878 0.471 0.48 0.0 0.0 + 0.162 0.076 -0.512 0.0 0.0 + 0.0 0.0 0.0 -0.9 0.835 + 0.0 0.0 0.0 0.415 -0.142
    julia> d1 = dim(codomain(t))25
    julia> d2 = dim(domain(t))9
    julia> (matrix = reshape(array, d1, d2)) |> disp25×9 Array{Float64, 2}: + 1.108 0.783 0.0 0.623 -0.328 0.0 0.0 0.0 0.325 + 0.051 0.269 0.0 -0.463 -0.24 0.0 0.0 0.0 0.878 + -0.342 0.67 0.0 0.059 -1.554 0.0 0.0 0.0 0.162 + 0.0 0.0 0.221 0.0 0.0 1.862 -0.319 0.31 0.0 + 0.0 0.0 0.596 0.0 0.0 -0.112 -0.114 0.391 0.0 + 0.964 -0.442 0.0 -0.399 0.332 0.0 0.0 0.0 0.48 + -0.946 -0.767 0.0 0.01 -0.417 0.0 0.0 0.0 0.471 + -0.568 0.173 0.0 -0.621 1.164 0.0 0.0 0.0 0.076 + 0.0 0.0 -0.597 0.0 0.0 0.691 -1.328 2.319 0.0 + 0.0 0.0 -0.167 0.0 0.0 -0.135 -0.055 -1.059 0.0 + 0.468 -0.393 0.0 -0.979 0.497 0.0 0.0 0.0 -0.666 + -0.873 -0.46 0.0 0.299 0.687 0.0 0.0 0.0 0.48 + 0.976 0.734 0.0 -0.222 -0.281 0.0 0.0 0.0 -0.512 + 0.0 0.0 -0.248 0.0 0.0 1.409 -0.729 1.094 0.0 + 0.0 0.0 -0.706 0.0 0.0 0.734 -2.141 -0.349 0.0 + 0.0 0.0 1.338 0.0 0.0 0.791 0.146 -0.483 0.0 + 0.0 0.0 0.618 0.0 0.0 0.346 0.782 -0.692 0.0 + 0.0 0.0 -1.725 0.0 0.0 -0.143 0.303 -0.096 0.0 + 0.497 1.459 0.0 0.616 1.798 0.0 0.0 0.0 -0.9 + 0.0 -0.695 0.0 0.126 0.706 0.0 0.0 0.0 0.415 + 0.0 0.0 0.708 0.0 0.0 0.274 -0.415 -1.098 0.0 + 0.0 0.0 -0.18 0.0 0.0 -1.261 0.6 0.12 0.0 + 0.0 0.0 -0.454 0.0 0.0 0.623 1.617 -0.284 0.0 + -0.415 -0.002 0.0 -0.562 -0.115 0.0 0.0 0.0 0.835 + -0.554 -0.454 0.0 0.967 0.776 0.0 0.0 0.0 -0.142
    julia> (u = reshape(convert(Array, unitary(codomain(t), fuse(codomain(t)))), d1, d1)) |> disp25×25 Array{Float64, 2}: 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 @@ -335,256 +328,256 @@ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0
    julia> u'*u ≈ I ≈ v'*vtrue
    julia> (u'*matrix*v) |> disp25×9 Array{Float64, 2}: - 0.742 0.351 -1.557 -0.043 0.678 0.0 0.0 0.0 0.0 - -0.029 -0.86 -0.295 -0.034 -0.309 0.0 0.0 0.0 0.0 - 0.265 -1.521 -0.196 -1.072 -0.399 0.0 0.0 0.0 0.0 - 0.55 0.479 2.071 -0.867 0.282 0.0 0.0 0.0 0.0 - -0.324 2.656 1.018 1.585 0.05 0.0 0.0 0.0 0.0 - 0.351 -1.408 0.283 0.125 -1.124 0.0 0.0 0.0 0.0 - -0.938 0.921 1.473 -1.828 0.865 0.0 0.0 0.0 0.0 - 0.416 1.226 -0.34 1.077 -0.105 0.0 0.0 0.0 0.0 - 0.31 0.756 -1.032 -1.662 0.628 0.0 0.0 0.0 0.0 - -0.724 -1.101 -0.868 -1.78 0.131 0.0 0.0 0.0 0.0 - -0.978 -0.097 0.213 2.015 0.504 0.0 0.0 0.0 0.0 - -0.772 1.073 -0.505 0.653 -0.256 0.0 0.0 0.0 0.0 - -1.606 -0.608 -1.292 -1.87 0.887 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 1.666 0.622 -0.236 0.671 - 0.0 0.0 0.0 0.0 0.0 -1.042 -0.962 -1.961 -1.753 - 0.0 0.0 0.0 0.0 0.0 -0.451 0.822 1.483 0.019 - 0.0 0.0 0.0 0.0 0.0 -0.847 -0.157 0.227 0.175 - 0.0 0.0 0.0 0.0 0.0 -0.103 -0.349 1.473 -1.526 - 0.0 0.0 0.0 0.0 0.0 0.926 -0.297 -0.079 0.764 - 0.0 0.0 0.0 0.0 0.0 -0.767 -0.971 -0.153 0.866 - 0.0 0.0 0.0 0.0 0.0 1.036 -0.303 -0.27 -0.956 - 0.0 0.0 0.0 0.0 0.0 -0.652 -1.528 -0.72 -0.856 - 0.0 0.0 0.0 0.0 0.0 -0.464 -1.253 -1.457 -0.475 - 0.0 0.0 0.0 0.0 0.0 0.428 -0.506 -0.871 0.914 - 0.0 0.0 0.0 0.0 0.0 0.002 -1.677 0.947 0.855
    julia> # compare with: + 1.108 0.783 0.623 -0.328 0.325 0.0 0.0 0.0 0.0 + 0.051 0.269 -0.463 -0.24 0.878 0.0 0.0 0.0 0.0 + -0.342 0.67 0.059 -1.554 0.162 0.0 0.0 0.0 0.0 + 0.964 -0.442 -0.399 0.332 0.48 0.0 0.0 0.0 0.0 + -0.946 -0.767 0.01 -0.417 0.471 0.0 0.0 0.0 0.0 + -0.568 0.173 -0.621 1.164 0.076 0.0 0.0 0.0 0.0 + 0.468 -0.393 -0.979 0.497 -0.666 0.0 0.0 0.0 0.0 + -0.873 -0.46 0.299 0.687 0.48 0.0 0.0 0.0 0.0 + 0.976 0.734 -0.222 -0.281 -0.512 0.0 0.0 0.0 0.0 + 0.497 1.459 0.616 1.798 -0.9 0.0 0.0 0.0 0.0 + 0.0 -0.695 0.126 0.706 0.415 0.0 0.0 0.0 0.0 + -0.415 -0.002 -0.562 -0.115 0.835 0.0 0.0 0.0 0.0 + -0.554 -0.454 0.967 0.776 -0.142 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.221 1.862 -0.319 0.31 + 0.0 0.0 0.0 0.0 0.0 0.596 -0.112 -0.114 0.391 + 0.0 0.0 0.0 0.0 0.0 -0.597 0.691 -1.328 2.319 + 0.0 0.0 0.0 0.0 0.0 -0.167 -0.135 -0.055 -1.059 + 0.0 0.0 0.0 0.0 0.0 -0.248 1.409 -0.729 1.094 + 0.0 0.0 0.0 0.0 0.0 -0.706 0.734 -2.141 -0.349 + 0.0 0.0 0.0 0.0 0.0 1.338 0.791 0.146 -0.483 + 0.0 0.0 0.0 0.0 0.0 0.618 0.346 0.782 -0.692 + 0.0 0.0 0.0 0.0 0.0 -1.725 -0.143 0.303 -0.096 + 0.0 0.0 0.0 0.0 0.0 0.708 0.274 -0.415 -1.098 + 0.0 0.0 0.0 0.0 0.0 -0.18 -1.261 0.6 0.12 + 0.0 0.0 0.0 0.0 0.0 -0.454 0.623 1.617 -0.284
    julia> # compare with: block(t, Z2Irrep(0)) |> disp13×5 Array{Float64, 2}: - 0.742 0.351 -1.557 -0.043 0.678 - -0.029 -0.86 -0.295 -0.034 -0.309 - 0.265 -1.521 -0.196 -1.072 -0.399 - 0.55 0.479 2.071 -0.867 0.282 - -0.324 2.656 1.018 1.585 0.05 - 0.351 -1.408 0.283 0.125 -1.124 - -0.938 0.921 1.473 -1.828 0.865 - 0.416 1.226 -0.34 1.077 -0.105 - 0.31 0.756 -1.032 -1.662 0.628 - -0.724 -1.101 -0.868 -1.78 0.131 - -0.978 -0.097 0.213 2.015 0.504 - -0.772 1.073 -0.505 0.653 -0.256 - -1.606 -0.608 -1.292 -1.87 0.887
    julia> block(t, Z2Irrep(1)) |> disp12×4 Array{Float64, 2}: - 1.666 0.622 -0.236 0.671 - -1.042 -0.962 -1.961 -1.753 - -0.451 0.822 1.483 0.019 - -0.847 -0.157 0.227 0.175 - -0.103 -0.349 1.473 -1.526 - 0.926 -0.297 -0.079 0.764 - -0.767 -0.971 -0.153 0.866 - 1.036 -0.303 -0.27 -0.956 - -0.652 -1.528 -0.72 -0.856 - -0.464 -1.253 -1.457 -0.475 - 0.428 -0.506 -0.871 0.914 - 0.002 -1.677 0.947 0.855

    Here, we illustrated some additional concepts. Firstly, note that we convert a TensorMap to an Array. This only works when sectortype(t) supports fusiontensor, and in particular when BraidingStyle(sectortype(t)) == Bosonic(), e.g. the case of trivial tensors (the category $\mathbf{Vect}$) and group representations (the category $\mathbf{Rep}_{\mathsf{G}}$, which can be interpreted as a subcategory of $\mathbf{Vect}$). Here, we are in this case with $\mathsf{G} = ℤ₂$. For a TensorMap{S,1,1}, the blocks directly correspond to the diagonal blocks in the block diagonal structure of its representation as an Array, there is no basis transform in between. This is no longer the case for TensorMap{S,N₁,N₂} with different values of N₁ and N₂. Here, we use the operation fuse(V), which creates an ElementarySpace which is isomorphic to a given space V (of type ProductSpace or ElementarySpace). The specific map between those two spaces constructed using the specific method unitary implements precisely the basis change from the product basis to the coupled basis. In this case, for a group G with FusionStyle(Irrep[G]) isa UniqueFusion, it is a permutation matrix. Specifically choosing V equal to the codomain and domain of t, we can construct the explicit basis transforms that bring t into block diagonal form.

    Let's repeat the same exercise for I = Irrep[SU₂], which has FusionStyle(I) isa MultipleFusion.

    julia> V1 = SU₂Space(0=>2,1=>1)Rep[SU₂](0=>2, 1=>1)
    julia> V2 = SU₂Space(0=>1,1=>1)Rep[SU₂](0=>1, 1=>1)
    julia> # First a `TensorMap{SU₂Space, 1, 1}` + 1.108 0.783 0.623 -0.328 0.325 + 0.051 0.269 -0.463 -0.24 0.878 + -0.342 0.67 0.059 -1.554 0.162 + 0.964 -0.442 -0.399 0.332 0.48 + -0.946 -0.767 0.01 -0.417 0.471 + -0.568 0.173 -0.621 1.164 0.076 + 0.468 -0.393 -0.979 0.497 -0.666 + -0.873 -0.46 0.299 0.687 0.48 + 0.976 0.734 -0.222 -0.281 -0.512 + 0.497 1.459 0.616 1.798 -0.9 + 0.0 -0.695 0.126 0.706 0.415 + -0.415 -0.002 -0.562 -0.115 0.835 + -0.554 -0.454 0.967 0.776 -0.142
    julia> block(t, Z2Irrep(1)) |> disp12×4 Array{Float64, 2}: + 0.221 1.862 -0.319 0.31 + 0.596 -0.112 -0.114 0.391 + -0.597 0.691 -1.328 2.319 + -0.167 -0.135 -0.055 -1.059 + -0.248 1.409 -0.729 1.094 + -0.706 0.734 -2.141 -0.349 + 1.338 0.791 0.146 -0.483 + 0.618 0.346 0.782 -0.692 + -1.725 -0.143 0.303 -0.096 + 0.708 0.274 -0.415 -1.098 + -0.18 -1.261 0.6 0.12 + -0.454 0.623 1.617 -0.284

    Here, we illustrated some additional concepts. Firstly, note that we convert a TensorMap to an Array. This only works when sectortype(t) supports fusiontensor, and in particular when BraidingStyle(sectortype(t)) == Bosonic(), e.g. the case of trivial tensors (the category $\mathbf{Vect}$) and group representations (the category $\mathbf{Rep}_{\mathsf{G}}$, which can be interpreted as a subcategory of $\mathbf{Vect}$). Here, we are in this case with $\mathsf{G} = ℤ₂$. For a TensorMap{S,1,1}, the blocks directly correspond to the diagonal blocks in the block diagonal structure of its representation as an Array, there is no basis transform in between. This is no longer the case for TensorMap{S,N₁,N₂} with different values of N₁ and N₂. Here, we use the operation fuse(V), which creates an ElementarySpace which is isomorphic to a given space V (of type ProductSpace or ElementarySpace). The specific map between those two spaces constructed using the specific method unitary implements precisely the basis change from the product basis to the coupled basis. In this case, for a group G with FusionStyle(Irrep[G]) isa UniqueFusion, it is a permutation matrix. Specifically choosing V equal to the codomain and domain of t, we can construct the explicit basis transforms that bring t into block diagonal form.

    Let's repeat the same exercise for I = Irrep[SU₂], which has FusionStyle(I) isa MultipleFusion.

    julia> V1 = SU₂Space(0=>2,1=>1)Rep[SU₂](0=>2, 1=>1)
    julia> V2 = SU₂Space(0=>1,1=>1)Rep[SU₂](0=>1, 1=>1)
    julia> # First a `TensorMap{SU₂Space, 1, 1}` m = TensorMap(randn, V1, V2)TensorMap(Rep[SU₂](0=>2, 1=>1) ← Rep[SU₂](0=>1, 1=>1)): * Data for fusiontree FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()): - 1.6079185612547917 - 1.3783359056024296 + 0.12502142580250492 + 0.03185341182692353 * Data for fusiontree FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()): - 2.09270183142595
    julia> convert(Array, m) |> disp5×4 Array{Float64, 2}: - 1.607 0.0 0.0 0.0 - 1.378 0.0 0.0 0.0 - 0.0 2.092 0.0 0.0 - 0.0 0.0 2.092 0.0 - 0.0 0.0 0.0 2.092
    julia> # compare with: + 1.6993281003070992
    julia> convert(Array, m) |> disp5×4 Array{Float64, 2}: + 0.125 0.0 0.0 0.0 + 0.031 0.0 0.0 0.0 + 0.0 1.699 0.0 0.0 + 0.0 0.0 1.699 0.0 + 0.0 0.0 0.0 1.699
    julia> # compare with: block(m, Irrep[SU₂](0)) |> disp2×1 Array{Float64, 2}: - 1.607 - 1.378
    julia> block(m, Irrep[SU₂](1)) |> disp1×1 Array{Float64, 2}: - 2.092
    julia> # Now a `TensorMap{SU₂Space, 2, 2}` + 0.125 + 0.031
    julia> block(m, Irrep[SU₂](1)) |> disp1×1 Array{Float64, 2}: + 1.699
    julia> # Now a `TensorMap{SU₂Space, 2, 2}` t = TensorMap(randn, V1 ⊗ V1, V2 ⊗ V2')TensorMap((Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>2, 1=>1)) ← (Rep[SU₂](0=>1, 1=>1) ⊗ Rep[SU₂](0=>1, 1=>1)')): * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0, 0), 0, (false, true), ()): [:, :, 1, 1] = - 0.7499680380670081 0.4678569183764747 - 0.2313104387776426 -2.160792498329961 + -2.2877360092623973 -0.4701137160451746 + -0.17830555412850074 1.1693881759308935 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0, 0), 0, (false, true), ()): [:, :, 1, 1] = - 0.004332203678615969 + 0.42677374712024574 * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 1), 0, (false, true), ()): [:, :, 1, 1] = - -0.2674752286809722 1.80056523339902 - -0.08604324342283884 2.211709076743206 + -0.7608585720696309 -0.1959592283340349 + -0.09131474391229825 -0.03886915766686538 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 1), 0, (false, true), ()): [:, :, 1, 1] = - -0.5121297156072518 + -1.1196711630969334 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0, 1), 1, (false, true), ()): [:, :, 1, 1] = - 1.1833963233665168 + 0.9138580245216501 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 0), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0, 1), 1, (false, true), ()): [:, :, 1, 1] = - -1.6584323019387064 -0.26715991355767765 + -1.8834989788658818 0.7934355411393117 * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0, 1), 1, (false, true), ()): [:, :, 1, 1] = - -1.0445284458302235 - 0.16947087479249068 + -0.17711370014702307 + -0.08807482267593125 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 1), 1, (false, true), ()): [:, :, 1, 1] = - -0.21836520209468674 + 1.3202465309604294 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 0), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 1), 1, (false, true), ()): [:, :, 1, 1] = - -1.3820375676344694 1.32722090068882 + 1.5013222929804988 -1.2099982241682534 * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 1), 1, (false, true), ()): [:, :, 1, 1] = - -1.5255716247541817 - -0.5705967412110532 + -0.7146358714051527 + 1.6271445886572724 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 0), 1, (false, true), ()): [:, :, 1, 1] = - -0.5627902971805271 + -0.01576943272674448 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 0), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 0), 1, (false, true), ()): [:, :, 1, 1] = - -0.6555927103633437 -0.476198185644982 + -1.8552406634645937 -0.5914021048583382 * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 0), 1, (false, true), ()): [:, :, 1, 1] = - -0.02119864116146894 - 0.2914215242489749 + 0.48451346873643386 + 1.015543168903234 * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 2, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1, 1), 2, (false, true), ()): [:, :, 1, 1] = - 1.1141125741427391
    julia> (array = convert(Array, t)) |> disp5×5×4×4 Array{Float64, 4}: + -0.4662059928284731
    julia> (array = convert(Array, t)) |> disp5×5×4×4 Array{Float64, 4}: [:, :, 1, 1] = - 0.749 0.467 0.0 0.0 0.0 - 0.231 -2.16 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.002 - 0.0 0.0 0.0 -0.002 0.0 - 0.0 0.0 0.002 0.0 0.0 + -2.287 -0.47 0.0 0.0 0.0 + -0.178 1.169 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.246 + 0.0 0.0 0.0 -0.246 0.0 + 0.0 0.0 0.246 0.0 0.0 [:, :, 2, 1] = - 0.0 0.0 -0.021 0.0 0.0 - 0.0 0.0 0.291 0.0 0.0 - -0.655 -0.476 0.0 -0.397 0.0 - 0.0 0.0 0.397 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.484 0.0 0.0 + 0.0 0.0 1.015 0.0 0.0 + -1.855 -0.591 0.0 -0.011 0.0 + 0.0 0.0 0.011 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 [:, :, 3, 1] = - 0.0 0.0 0.0 -0.021 0.0 - 0.0 0.0 0.0 0.291 0.0 - 0.0 0.0 0.0 0.0 -0.397 - -0.655 -0.476 0.0 0.0 0.0 - 0.0 0.0 0.397 0.0 0.0 + 0.0 0.0 0.0 0.484 0.0 + 0.0 0.0 0.0 1.015 0.0 + 0.0 0.0 0.0 0.0 -0.011 + -1.855 -0.591 0.0 0.0 0.0 + 0.0 0.0 0.011 0.0 0.0 [:, :, 4, 1] = - 0.0 0.0 0.0 0.0 -0.021 - 0.0 0.0 0.0 0.0 0.291 + 0.0 0.0 0.0 0.0 0.484 + 0.0 0.0 0.0 0.0 1.015 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.397 - -0.655 -0.476 0.0 0.397 0.0 + 0.0 0.0 0.0 0.0 -0.011 + -1.855 -0.591 0.0 0.011 0.0 [:, :, 1, 2] = - 0.0 0.0 0.0 0.0 -1.044 - 0.0 0.0 0.0 0.0 0.169 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.836 - -1.658 -0.267 0.0 -0.836 0.0 + 0.0 0.0 0.0 0.0 -0.177 + 0.0 0.0 0.0 0.0 -0.088 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.646 + -1.883 0.793 0.0 -0.646 0.0 [:, :, 2, 2] = - -0.154 1.039 0.0 -1.078 0.0 - -0.049 1.276 0.0 -0.403 0.0 - 0.0 0.0 0.0 0.0 -0.094 - -0.977 0.938 0.0 0.542 0.0 - 0.0 0.0 0.124 0.0 0.0 + -0.439 -0.113 0.0 -0.505 0.0 + -0.052 -0.022 0.0 1.15 0.0 + 0.0 0.0 0.0 0.0 0.209 + 1.061 -0.855 0.0 0.217 0.0 + 0.0 0.0 -1.111 0.0 0.0 [:, :, 3, 2] = - 0.0 0.0 0.0 0.0 -1.078 - 0.0 0.0 0.0 0.0 -0.403 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.447 - -0.977 0.938 0.0 0.666 0.0 + 0.0 0.0 0.0 0.0 -0.505 + 0.0 0.0 0.0 0.0 1.15 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.427 + 1.061 -0.855 0.0 -0.893 0.0 [:, :, 4, 2] = - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 1.114 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -0.466 [:, :, 1, 3] = - 0.0 0.0 0.0 1.044 0.0 - 0.0 0.0 0.0 -0.169 0.0 - 0.0 0.0 0.0 0.0 -0.836 - 1.658 0.267 0.0 0.0 0.0 - 0.0 0.0 0.836 0.0 0.0 + 0.0 0.0 0.0 0.177 0.0 + 0.0 0.0 0.0 0.088 0.0 + 0.0 0.0 0.0 0.0 -0.646 + 1.883 -0.793 0.0 0.0 0.0 + 0.0 0.0 0.646 0.0 0.0 [:, :, 2, 3] = - 0.0 0.0 1.078 0.0 0.0 - 0.0 0.0 0.403 0.0 0.0 - 0.977 -0.938 0.0 -0.447 0.0 - 0.0 0.0 -0.666 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.505 0.0 0.0 + 0.0 0.0 -1.15 0.0 0.0 + -1.061 0.855 0.0 -0.427 0.0 + 0.0 0.0 0.893 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 [:, :, 3, 3] = - -0.154 1.039 0.0 0.0 0.0 - -0.049 1.276 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.542 - 0.0 0.0 0.0 -0.572 0.0 - 0.0 0.0 -0.542 0.0 0.0 + -0.439 -0.113 0.0 0.0 0.0 + -0.052 -0.022 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -0.217 + 0.0 0.0 0.0 0.684 0.0 + 0.0 0.0 -0.217 0.0 0.0 [:, :, 4, 3] = - 0.0 0.0 0.0 0.0 -1.078 - 0.0 0.0 0.0 0.0 -0.403 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.666 - -0.977 0.938 0.0 -0.447 0.0 + 0.0 0.0 0.0 0.0 -0.505 + 0.0 0.0 0.0 0.0 1.15 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.893 + 1.061 -0.855 0.0 -0.427 0.0 [:, :, 1, 4] = - 0.0 0.0 -1.044 0.0 0.0 - 0.0 0.0 0.169 0.0 0.0 - -1.658 -0.267 0.0 0.836 0.0 - 0.0 0.0 -0.836 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 -0.177 0.0 0.0 + 0.0 0.0 -0.088 0.0 0.0 + -1.883 0.793 0.0 0.646 0.0 + 0.0 0.0 -0.646 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 [:, :, 2, 4] = - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 1.114 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 -0.466 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 [:, :, 3, 4] = - 0.0 0.0 1.078 0.0 0.0 - 0.0 0.0 0.403 0.0 0.0 - 0.977 -0.938 0.0 0.666 0.0 - 0.0 0.0 0.447 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.505 0.0 0.0 + 0.0 0.0 -1.15 0.0 0.0 + -1.061 0.855 0.0 -0.893 0.0 + 0.0 0.0 0.427 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 [:, :, 4, 4] = - -0.154 1.039 0.0 1.078 0.0 - -0.049 1.276 0.0 0.403 0.0 - 0.0 0.0 0.0 0.0 0.124 - 0.977 -0.938 0.0 0.542 0.0 - 0.0 0.0 -0.094 0.0 0.0
    julia> d1 = dim(codomain(t))25
    julia> d2 = dim(domain(t))16
    julia> (matrix = reshape(array, d1, d2)) |> disp25×16 Array{Float64, 2}: - 0.749 0.0 0.0 0.0 0.0 -0.154 0.0 0.0 0.0 0.0 -0.154 0.0 0.0 0.0 0.0 -0.154 - 0.231 0.0 0.0 0.0 0.0 -0.049 0.0 0.0 0.0 0.0 -0.049 0.0 0.0 0.0 0.0 -0.049 - 0.0 -0.655 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.977 0.0 0.0 -1.658 0.0 0.977 0.0 - 0.0 0.0 -0.655 0.0 0.0 -0.977 0.0 0.0 1.658 0.0 0.0 0.0 0.0 0.0 0.0 0.977 - 0.0 0.0 0.0 -0.655 -1.658 0.0 -0.977 0.0 0.0 0.0 0.0 -0.977 0.0 0.0 0.0 0.0 - 0.467 0.0 0.0 0.0 0.0 1.039 0.0 0.0 0.0 0.0 1.039 0.0 0.0 0.0 0.0 1.039 - -2.16 0.0 0.0 0.0 0.0 1.276 0.0 0.0 0.0 0.0 1.276 0.0 0.0 0.0 0.0 1.276 - 0.0 -0.476 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.938 0.0 0.0 -0.267 0.0 -0.938 0.0 - 0.0 0.0 -0.476 0.0 0.0 0.938 0.0 0.0 0.267 0.0 0.0 0.0 0.0 0.0 0.0 -0.938 - 0.0 0.0 0.0 -0.476 -0.267 0.0 0.938 0.0 0.0 0.0 0.0 0.938 0.0 0.0 0.0 0.0 - 0.0 -0.021 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.078 0.0 0.0 -1.044 0.0 1.078 0.0 - 0.0 0.291 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.403 0.0 0.0 0.169 0.0 0.403 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.114 0.0 0.0 - 0.0 0.397 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.666 0.0 0.0 -0.836 0.0 0.447 0.0 - 0.002 0.0 0.397 0.0 0.0 0.124 0.0 0.0 0.836 0.0 -0.542 0.0 0.0 0.0 0.0 -0.094 - 0.0 0.0 -0.021 0.0 0.0 -1.078 0.0 0.0 1.044 0.0 0.0 0.0 0.0 0.0 0.0 1.078 - 0.0 0.0 0.291 0.0 0.0 -0.403 0.0 0.0 -0.169 0.0 0.0 0.0 0.0 0.0 0.0 0.403 - 0.0 -0.397 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.447 0.0 0.0 0.836 0.0 0.666 0.0 - -0.002 0.0 0.0 0.0 0.0 0.542 0.0 0.0 0.0 0.0 -0.572 0.0 0.0 0.0 0.0 0.542 - 0.0 0.0 0.0 0.397 -0.836 0.0 0.666 0.0 0.0 0.0 0.0 -0.447 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 -0.021 -1.044 0.0 -1.078 0.0 0.0 0.0 0.0 -1.078 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.291 0.169 0.0 -0.403 0.0 0.0 0.0 0.0 -0.403 0.0 0.0 0.0 0.0 - 0.002 0.0 -0.397 0.0 0.0 -0.094 0.0 0.0 -0.836 0.0 -0.542 0.0 0.0 0.0 0.0 0.124 - 0.0 0.0 0.0 -0.397 0.836 0.0 0.447 0.0 0.0 0.0 0.0 -0.666 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.114 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
    julia> (u = reshape(convert(Array, unitary(codomain(t), fuse(codomain(t)))), d1, d1)) |> disp25×25 Array{Float64, 2}: + -0.439 -0.113 0.0 0.505 0.0 + -0.052 -0.022 0.0 -1.15 0.0 + 0.0 0.0 0.0 0.0 -1.111 + -1.061 0.855 0.0 0.217 0.0 + 0.0 0.0 0.209 0.0 0.0
    julia> d1 = dim(codomain(t))25
    julia> d2 = dim(domain(t))16
    julia> (matrix = reshape(array, d1, d2)) |> disp25×16 Array{Float64, 2}: + -2.287 0.0 0.0 0.0 0.0 -0.439 0.0 0.0 0.0 0.0 -0.439 0.0 0.0 0.0 0.0 -0.439 + -0.178 0.0 0.0 0.0 0.0 -0.052 0.0 0.0 0.0 0.0 -0.052 0.0 0.0 0.0 0.0 -0.052 + 0.0 -1.855 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.061 0.0 0.0 -1.883 0.0 -1.061 0.0 + 0.0 0.0 -1.855 0.0 0.0 1.061 0.0 0.0 1.883 0.0 0.0 0.0 0.0 0.0 0.0 -1.061 + 0.0 0.0 0.0 -1.855 -1.883 0.0 1.061 0.0 0.0 0.0 0.0 1.061 0.0 0.0 0.0 0.0 + -0.47 0.0 0.0 0.0 0.0 -0.113 0.0 0.0 0.0 0.0 -0.113 0.0 0.0 0.0 0.0 -0.113 + 1.169 0.0 0.0 0.0 0.0 -0.022 0.0 0.0 0.0 0.0 -0.022 0.0 0.0 0.0 0.0 -0.022 + 0.0 -0.591 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.855 0.0 0.0 0.793 0.0 0.855 0.0 + 0.0 0.0 -0.591 0.0 0.0 -0.855 0.0 0.0 -0.793 0.0 0.0 0.0 0.0 0.0 0.0 0.855 + 0.0 0.0 0.0 -0.591 0.793 0.0 -0.855 0.0 0.0 0.0 0.0 -0.855 0.0 0.0 0.0 0.0 + 0.0 0.484 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.505 0.0 0.0 -0.177 0.0 0.505 0.0 + 0.0 1.015 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.15 0.0 0.0 -0.088 0.0 -1.15 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466 0.0 0.0 + 0.0 0.011 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.893 0.0 0.0 -0.646 0.0 0.427 0.0 + 0.246 0.0 0.011 0.0 0.0 -1.111 0.0 0.0 0.646 0.0 -0.217 0.0 0.0 0.0 0.0 0.209 + 0.0 0.0 0.484 0.0 0.0 -0.505 0.0 0.0 0.177 0.0 0.0 0.0 0.0 0.0 0.0 0.505 + 0.0 0.0 1.015 0.0 0.0 1.15 0.0 0.0 0.088 0.0 0.0 0.0 0.0 0.0 0.0 -1.15 + 0.0 -0.011 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.427 0.0 0.0 0.646 0.0 -0.893 0.0 + -0.246 0.0 0.0 0.0 0.0 0.217 0.0 0.0 0.0 0.0 0.684 0.0 0.0 0.0 0.0 0.217 + 0.0 0.0 0.0 0.011 -0.646 0.0 -0.893 0.0 0.0 0.0 0.0 -0.427 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.484 -0.177 0.0 -0.505 0.0 0.0 0.0 0.0 -0.505 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 1.015 -0.088 0.0 1.15 0.0 0.0 0.0 0.0 1.15 0.0 0.0 0.0 0.0 + 0.246 0.0 -0.011 0.0 0.0 0.209 0.0 0.0 -0.646 0.0 -0.217 0.0 0.0 0.0 0.0 -1.111 + 0.0 0.0 0.0 -0.011 0.646 0.0 0.427 0.0 0.0 0.0 0.0 0.893 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
    julia> (u = reshape(convert(Array, unitary(codomain(t), fuse(codomain(t)))), d1, d1)) |> disp25×25 Array{Float64, 2}: 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 @@ -626,57 +619,57 @@ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.999 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.707 0.0 0.0 0.0 0.707 0.0 0.0 0.0 0.0 0.577 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.707 0.0 0.0 0.0 0.408 0.0 0.0
    julia> u'*u ≈ I ≈ v'*vtrue
    julia> (u'*matrix*v) |> disp25×16 Array{Float64, 2}: - 0.749 -0.267 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.231 -0.086 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.467 1.8 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - -2.16 2.211 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.004 -0.512 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 -0.0 0.0 0.0 0.0 -0.0 0.0 0.0 - 0.0 0.0 -0.655 0.0 0.0 -1.658 0.0 0.0 -1.382 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 -0.655 0.0 0.0 -1.658 0.0 0.0 -1.382 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.655 0.0 0.0 -1.658 0.0 0.0 -1.382 0.0 0.0 0.0 -0.0 0.0 - 0.0 0.0 -0.476 0.0 0.0 -0.267 0.0 0.0 1.327 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 - 0.0 -0.0 0.0 -0.476 0.0 0.0 -0.267 0.0 0.0 1.327 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.476 0.0 0.0 -0.267 0.0 0.0 1.327 0.0 0.0 0.0 -0.0 0.0 - 0.0 0.0 -0.021 0.0 0.0 -1.044 0.0 0.0 -1.525 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 -0.0 0.0 -0.021 0.0 0.0 -1.044 0.0 0.0 -1.525 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.021 0.0 0.0 -1.044 0.0 0.0 -1.525 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.291 0.0 0.0 0.169 0.0 0.0 -0.57 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 -0.0 0.0 0.291 0.0 0.0 0.169 0.0 0.0 -0.57 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.291 0.0 0.0 0.169 0.0 0.0 -0.57 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 -0.562 0.0 0.0 1.183 0.0 0.0 -0.218 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 - 0.0 -0.0 0.0 -0.562 0.0 0.0 1.183 0.0 0.0 -0.218 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.562 0.0 0.0 1.183 0.0 0.0 -0.218 0.0 0.0 0.0 -0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.114 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.114 0.0 0.0 0.0 - -0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 1.114 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.114 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.114
    julia> # compare with: + -2.287 -0.76 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + -0.178 -0.091 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 + -0.47 -0.195 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 + 1.169 -0.038 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.426 -1.119 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 -1.855 0.0 0.0 -1.883 0.0 0.0 1.501 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 -1.855 0.0 0.0 -1.883 0.0 0.0 1.501 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -1.855 0.0 0.0 -1.883 0.0 0.0 1.501 0.0 0.0 0.0 -0.0 0.0 + 0.0 0.0 -0.591 0.0 0.0 0.793 0.0 0.0 -1.209 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 + 0.0 -0.0 0.0 -0.591 0.0 0.0 0.793 0.0 0.0 -1.209 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -0.591 0.0 0.0 0.793 0.0 0.0 -1.209 0.0 0.0 0.0 -0.0 0.0 + 0.0 0.0 0.484 0.0 0.0 -0.177 0.0 0.0 -0.714 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 -0.0 0.0 0.484 0.0 0.0 -0.177 0.0 0.0 -0.714 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.484 0.0 0.0 -0.177 0.0 0.0 -0.714 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 1.015 0.0 0.0 -0.088 0.0 0.0 1.627 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 1.015 0.0 0.0 -0.088 0.0 0.0 1.627 0.0 0.0 0.0 -0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 1.015 0.0 0.0 -0.088 0.0 0.0 1.627 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 -0.015 0.0 0.0 0.913 0.0 0.0 1.32 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 + -0.0 -0.0 0.0 -0.015 0.0 0.0 0.913 0.0 0.0 1.32 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -0.015 0.0 0.0 0.913 0.0 0.0 1.32 0.0 0.0 0.0 -0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 -0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.466
    julia> # compare with: block(t, SU2Irrep(0)) |> disp5×2 Array{Float64, 2}: - 0.749 -0.267 - 0.231 -0.086 - 0.467 1.8 - -2.16 2.211 - 0.004 -0.512
    julia> block(t, SU2Irrep(1)) |> disp5×3 Array{Float64, 2}: - -0.655 -1.658 -1.382 - -0.476 -0.267 1.327 - -0.021 -1.044 -1.525 - 0.291 0.169 -0.57 - -0.562 1.183 -0.218
    julia> block(t, SU2Irrep(2)) |> disp1×1 Array{Float64, 2}: - 1.114

    Note that the basis transforms u and v are no longer permutation matrices, but are still unitary. Furthermore, note that they render the tensor block diagonal, but that now every element of the diagonal blocks labeled by c comes itself in a tensor product with an identity matrix of size dim(c), i.e. dim(SU2Irrep(1)) = 3 and dim(SU2Irrep(2)) = 5.

    Tensor properties

    Given a t::AbstractTensorMap{S,N₁,N₂}, there are various methods to query its properties. The most important are clearly codomain(t) and domain(t). For t::AbstractTensor{S,N}, i.e. t::AbstractTensorMap{S,N,0}, we can use space(t) as synonym for codomain(t). However, for a general AbstractTensorMap this has no meaning. However, we can query space(t, i), the space associated with the ith index. For i ∈ 1:N₁, this corresponds to codomain(t, i) = codomain(t)[i]. For j = i-N₁ ∈ (1:N₂), this corresponds to dual(domain(t, j)) = dual(domain(t)[j]).

    The total number of indices, i.e. N₁+N₂, is given by numind(t), with N₁ == numout(t) and N₂ == numin(t), the number of outgoing and incoming indices. There are also the unexported methods TensorKit.codomainind(t) and TensorKit.domainind(t) which return the tuples (1, 2, …, N₁) and (N₁+1, …, N₁+N₂), and are useful for internal purposes. The type parameter S<:ElementarySpace can be obtained as spacetype(t); the corresponding sector can directly obtained as sectortype(t) and is Trivial when S != GradedSpace. The underlying field scalars of S can also directly be obtained as field(t). This is different from eltype(t), which returns the type of Number in the tensor data, i.e. the type parameter T in the (subtype of) DenseMatrix{T} in which the matrix blocks are stored. Note that during construction, a (one-time) warning is printed if !(T ⊂ field(S)). The specific DenseMatrix{T} subtype in which the tensor data is stored is obtained as storagetype(t). Each of the methods numind, numout, numin, TensorKit.codomainind, TensorKit.domainind, spacetype, sectortype, field, eltype and storagetype work in the type domain as well, i.e. they are encoded in typeof(t).

    Finally, there are methods to probe the data, which we already encountered. blocksectors(t) returns an iterator over the different coupled sectors that can be obtained from fusing the uncoupled sectors available in the domain, but they must also be obtained from fusing the uncoupled sectors available in the codomain (i.e. it is the intersection of both blocksectors(codomain(t)) and blocksectors(domain(t))). For a specific sector c ∈ blocksectors(t), block(t, c) returns the corresponding data. Both are obtained together with blocks(t), which returns an iterator over the pairs c=>block(t, c). Furthermore, there is fusiontrees(t) which returns an iterator over splitting-fusion tree pairs (f₁,f₂), for which the corresponding data is given by t[f₁,f₂] (i.e. using Base.getindex).

    Let's again illustrate these methods with an example, continuing with the tensor t from the previous example

    julia> typeof(t)TensorMap{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 2, 2, SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Matrix{Float64}}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}
    julia> codomain(t)(Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>2, 1=>1))
    julia> domain(t)(Rep[SU₂](0=>1, 1=>1) ⊗ Rep[SU₂](0=>1, 1=>1)')
    julia> space(t,1)Rep[SU₂](0=>2, 1=>1)
    julia> space(t,2)Rep[SU₂](0=>2, 1=>1)
    julia> space(t,3)Rep[SU₂](0=>1, 1=>1)'
    julia> space(t,4)Rep[SU₂](0=>1, 1=>1)
    julia> numind(t)4
    julia> numout(t)2
    julia> numin(t)2
    julia> spacetype(t)GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}
    julia> sectortype(t)SU2Irrep
    julia> field(t)
    julia> eltype(t)Float64
    julia> storagetype(t)Matrix{Float64} (alias for Array{Float64, 2})
    julia> blocksectors(t)3-element Vector{SU2Irrep}: + -2.287 -0.76 + -0.178 -0.091 + -0.47 -0.195 + 1.169 -0.038 + 0.426 -1.119
    julia> block(t, SU2Irrep(1)) |> disp5×3 Array{Float64, 2}: + -1.855 -1.883 1.501 + -0.591 0.793 -1.209 + 0.484 -0.177 -0.714 + 1.015 -0.088 1.627 + -0.015 0.913 1.32
    julia> block(t, SU2Irrep(2)) |> disp1×1 Array{Float64, 2}: + -0.466

    Note that the basis transforms u and v are no longer permutation matrices, but are still unitary. Furthermore, note that they render the tensor block diagonal, but that now every element of the diagonal blocks labeled by c comes itself in a tensor product with an identity matrix of size dim(c), i.e. dim(SU2Irrep(1)) = 3 and dim(SU2Irrep(2)) = 5.

    Tensor properties

    Given a t::AbstractTensorMap{S,N₁,N₂}, there are various methods to query its properties. The most important are clearly codomain(t) and domain(t). For t::AbstractTensor{S,N}, i.e. t::AbstractTensorMap{S,N,0}, we can use space(t) as synonym for codomain(t). However, for a general AbstractTensorMap this has no meaning. However, we can query space(t, i), the space associated with the ith index. For i ∈ 1:N₁, this corresponds to codomain(t, i) = codomain(t)[i]. For j = i-N₁ ∈ (1:N₂), this corresponds to dual(domain(t, j)) = dual(domain(t)[j]).

    The total number of indices, i.e. N₁+N₂, is given by numind(t), with N₁ == numout(t) and N₂ == numin(t), the number of outgoing and incoming indices. There are also the unexported methods TensorKit.codomainind(t) and TensorKit.domainind(t) which return the tuples (1, 2, …, N₁) and (N₁+1, …, N₁+N₂), and are useful for internal purposes. The type parameter S<:ElementarySpace can be obtained as spacetype(t); the corresponding sector can directly obtained as sectortype(t) and is Trivial when S != GradedSpace. The underlying field scalars of S can also directly be obtained as field(t). This is different from eltype(t), which returns the type of Number in the tensor data, i.e. the type parameter T in the (subtype of) DenseMatrix{T} in which the matrix blocks are stored. Note that during construction, a (one-time) warning is printed if !(T ⊂ field(S)). The specific DenseMatrix{T} subtype in which the tensor data is stored is obtained as storagetype(t). Each of the methods numind, numout, numin, TensorKit.codomainind, TensorKit.domainind, spacetype, sectortype, field, eltype and storagetype work in the type domain as well, i.e. they are encoded in typeof(t).

    Finally, there are methods to probe the data, which we already encountered. blocksectors(t) returns an iterator over the different coupled sectors that can be obtained from fusing the uncoupled sectors available in the domain, but they must also be obtained from fusing the uncoupled sectors available in the codomain (i.e. it is the intersection of both blocksectors(codomain(t)) and blocksectors(domain(t))). For a specific sector c ∈ blocksectors(t), block(t, c) returns the corresponding data. Both are obtained together with blocks(t), which returns an iterator over the pairs c=>block(t, c). Furthermore, there is fusiontrees(t) which returns an iterator over splitting-fusion tree pairs (f₁,f₂), for which the corresponding data is given by t[f₁,f₂] (i.e. using Base.getindex).

    Let's again illustrate these methods with an example, continuing with the tensor t from the previous example

    julia> typeof(t)TensorMap{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 2, 2, SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Matrix{Float64}}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}
    julia> codomain(t)(Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>2, 1=>1))
    julia> domain(t)(Rep[SU₂](0=>1, 1=>1) ⊗ Rep[SU₂](0=>1, 1=>1)')
    julia> space(t,1)Rep[SU₂](0=>2, 1=>1)
    julia> space(t,2)Rep[SU₂](0=>2, 1=>1)
    julia> space(t,3)Rep[SU₂](0=>1, 1=>1)'
    julia> space(t,4)Rep[SU₂](0=>1, 1=>1)
    julia> numind(t)4
    julia> numout(t)2
    julia> numin(t)2
    julia> spacetype(t)GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}
    julia> sectortype(t)SU2Irrep
    julia> field(t)
    julia> eltype(t)Float64
    julia> storagetype(t)Matrix{Float64} (alias for Array{Float64, 2})
    julia> blocksectors(t)3-element Vector{SU2Irrep}: 0 1 2
    julia> blocks(t)TensorKit.SortedVectorDict{SU2Irrep, Matrix{Float64}} with 3 entries: - 0 => [0.749968 -0.267475; 0.23131 -0.0860432; … ; -2.16079 2.21171; 0.0043322… - 1 => [-0.655593 -1.65843 -1.38204; -0.476198 -0.26716 1.32722; … ; 0.291422 0… - 2 => [1.11411;;]
    julia> block(t, first(blocksectors(t)))5×2 Matrix{Float64}: - 0.749968 -0.267475 - 0.23131 -0.0860432 - 0.467857 1.80057 - -2.16079 2.21171 - 0.0043322 -0.51213
    julia> fusiontrees(t)TensorKit.TensorKeyIterator{SU2Irrep, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}(TensorKit.SortedVectorDict{SU2Irrep, Dict{FusionTree{SU2Irrep, 2, 0, 1, Nothing}, UnitRange{Int64}}}(0 => Dict(FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()) => 1:4, FusionTree{Irrep[SU₂]}((1, 1), 0, (false, false), ()) => 5:5), 1 => Dict(FusionTree{Irrep[SU₂]}((1, 1), 1, (false, false), ()) => 5:5, FusionTree{Irrep[SU₂]}((1, 0), 1, (false, false), ()) => 1:2, FusionTree{Irrep[SU₂]}((0, 1), 1, (false, false), ()) => 3:4), 2 => Dict(FusionTree{Irrep[SU₂]}((1, 1), 2, (false, false), ()) => 1:1)), TensorKit.SortedVectorDict{SU2Irrep, Dict{FusionTree{SU2Irrep, 2, 0, 1, Nothing}, UnitRange{Int64}}}(0 => Dict(FusionTree{Irrep[SU₂]}((0, 0), 0, (false, true), ()) => 1:1, FusionTree{Irrep[SU₂]}((1, 1), 0, (false, true), ()) => 2:2), 1 => Dict(FusionTree{Irrep[SU₂]}((0, 1), 1, (false, true), ()) => 2:2, FusionTree{Irrep[SU₂]}((1, 1), 1, (false, true), ()) => 3:3, FusionTree{Irrep[SU₂]}((1, 0), 1, (false, true), ()) => 1:1), 2 => Dict(FusionTree{Irrep[SU₂]}((1, 1), 2, (false, true), ()) => 1:1)))
    julia> f1, f2 = first(fusiontrees(t))(FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()), FusionTree{Irrep[SU₂]}((0, 0), 0, (false, true), ()))
    julia> t[f1,f2]2×2×1×1 StridedViews.StridedView{Float64, 4, Matrix{Float64}, typeof(identity)}: -[:, :, 1, 1] = - 0.749968 0.467857 - 0.23131 -2.16079

    Reading and writing tensors: Dict conversion

    There are no custom or dedicated methods for reading, writing or storing TensorMaps, however, there is the possibility to convert a t::AbstractTensorMap into a Dict, simply as convert(Dict, t). The backward conversion convert(TensorMap, dict) will return a tensor that is equal to t, i.e. t == convert(TensorMap, convert(Dict, t)).

    This conversion relies on that the string represenation of objects such as VectorSpace, FusionTree or Sector should be such that it represents valid code to recreate the object. Hence, we store information about the domain and codomain of the tensor, and the sector associated with each data block, as a String obtained with repr. This provides the flexibility to still change the internal structure of such objects, without this breaking the ability to load older data files. The resulting dictionary can then be stored using any of the provided Julia packages such as JLD.jl, JLD2.jl, BSON.jl, JSON.jl, ...

    Vector space and linear algebra operations

    AbstractTensorMap instances t represent linear maps, i.e. homomorphisms in a 𝕜-linear category, just like matrices. To a large extent, they follow the interface of Matrix in Julia's LinearAlgebra standard library. Many methods from LinearAlgebra are (re)exported by TensorKit.jl, and can then us be used without using LinearAlgebra explicitly. In all of the following methods, the implementation acts directly on the underlying matrix blocks (typically using the same method) and never needs to perform any basis transforms.

    In particular, AbstractTensorMap instances can be composed, provided the domain of the first object coincides with the codomain of the second. Composing tensor maps uses the regular multiplication symbol as in t = t1*t2, which is also used for matrix multiplication. TensorKit.jl also supports (and exports) the mutating method mul!(t, t1, t2). We can then also try to invert a tensor map using inv(t), though this can only exist if the domain and codomain are isomorphic, which can e.g. be checked as fuse(codomain(t)) == fuse(domain(t)). If the inverse is composed with another tensor t2, we can use the syntax t1\t2 or t2/t1. However, this syntax also accepts instances t1 whose domain and codomain are not isomorphic, and then amounts to pinv(t1), the Moore-Penrose pseudoinverse. This, however, is only really justified as minimizing the least squares problem if InnerProductStyle(t) <: EuclideanProduct.

    AbstractTensorMap instances behave themselves as vectors (i.e. they are 𝕜-linear) and so they can be multiplied by scalars and, if they live in the same space, i.e. have the same domain and codomain, they can be added to each other. There is also a zero(t), the additive identity, which produces a zero tensor with the same domain and codomain as t. In addition, TensorMap supports basic Julia methods such as fill! and copyto!, as well as copy(t) to create a copy with independent data. Aside from basic + and * operations, TensorKit.jl reexports a number of efficient in-place methods from LinearAlgebra, such as axpy! (for y ← α * x + y), axpby! (for y ← α * x + β * y), lmul! and rmul! (for y ← α*y and y ← y*α, which is typically the same) and mul!, which can also be used for out-of-place scalar multiplication y ← α*x.

    For t::AbstractTensorMap{S} where InnerProductStyle(S) <: EuclideanProduct, we can compute norm(t), and for two such instances, the inner product dot(t1, t2), provided t1 and t2 have the same domain and codomain. Furthermore, there is normalize(t) and normalize!(t) to return a scaled version of t with unit norm. These operations should also exist for InnerProductStyle(S) <: HasInnerProduct, but require an interface for defining a custom inner product in these spaces. Currently, there is no concrete subtype of HasInnerProduct that is not an EuclideanProduct. In particular, CartesianSpace, ComplexSpace and GradedSpace all have InnerProductStyle(V) <: EuclideanProduct.

    With tensors that have InnerProductStyle(t) <: EuclideanProduct there is associated an adjoint operation, given by adjoint(t) or simply t', such that domain(t') == codomain(t) and codomain(t') == domain(t). Note that for an instance t::TensorMap{S,N₁,N₂}, t' is simply stored in a wrapper called AdjointTensorMap{S,N₂,N₁}, which is another subtype of AbstractTensorMap. This should be mostly unvisible to the user, as all methods should work for this type as well. It can be hard to reason about the index order of t', i.e. index i of t appears in t' at index position j = TensorKit.adjointtensorindex(t, i), where the latter method is typically not necessary and hence unexported. There is also a plural TensorKit.adjointtensorindices to convert multiple indices at once. Note that, because the adjoint interchanges domain and codomain, we have space(t', j) == space(t, i)'.

    AbstractTensorMap instances can furthermore be tested for exact (t1 == t2) or approximate (t1 ≈ t2) equality, though the latter requires that norm can be computed.

    When tensor map instances are endomorphisms, i.e. they have the same domain and codomain, there is a multiplicative identity which can be obtained as one(t) or one!(t), where the latter overwrites the contents of t. The multiplicative identity on a space V can also be obtained using id(A, V) as discussed above, such that for a general homomorphism t′, we have t′ == id(codomain(t′))*t′ == t′*id(domain(t′)). Returning to the case of endomorphisms t, we can compute the trace via tr(t) and exponentiate them using exp(t), or if the contents of t can be destroyed in the process, exp!(t). Furthermore, there are a number of tensor factorizations for both endomorphisms and general homomorphism that we discuss below.

    Finally, there are a number of operations that also belong in this paragraph because of their analogy to common matrix operations. The tensor product of two TensorMap instances t1 and t2 is obtained as t1 ⊗ t2 and results in a new TensorMap with codomain(t1⊗t2) = codomain(t1) ⊗ codomain(t2) and domain(t1⊗t2) = domain(t1) ⊗ domain(t2). If we have two TensorMap{S,N,1} instances t1 and t2 with the same codomain, we can combine them in a way that is analoguous to hcat, i.e. we stack them such that the new tensor catdomain(t1, t2) has also the same codomain, but has a domain which is domain(t1) ⊕ domain(t2). Similarly, if t1 and t2 are of type TensorMap{S,1,N} and have the same domain, the operation catcodomain(t1, t2) results in a new tensor with the same domain and a codomain given by codomain(t1) ⊕ codomain(t2), which is the analogy of vcat. Note that direct sum only makes sense between ElementarySpace objects, i.e. there is no way to give a tensor product meaning to a direct sum of tensor product spaces.

    Time for some more examples:

    julia> t == t + zero(t) == t*id(domain(t)) == id(codomain(t))*ttrue
    julia> t2 = TensorMap(randn, ComplexF64, codomain(t), domain(t));
    julia> dot(t2, t)-2.633269175258879 + 5.576126506946093im
    julia> tr(t2'*t)-2.633269175258878 + 5.576126506946093im
    julia> dot(t2, t) ≈ dot(t', t2')true
    julia> dot(t2, t2)77.304834225791 + 0.0im
    julia> norm(t2)^277.304834225791
    julia> t3 = copyto!(similar(t, ComplexF64), t);ERROR: MethodError: no method matching copyto!(::TensorMap{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 2, 2, SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Matrix{ComplexF64}}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}, ::TensorMap{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 2, 2, SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Matrix{Float64}}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}) + 0 => [-2.28774 -0.760859; -0.178306 -0.0913147; … ; 1.16939 -0.0388692; 0.426… + 1 => [-1.85524 -1.8835 1.50132; -0.591402 0.793436 -1.21; … ; 1.01554 -0.0880… + 2 => [-0.466206;;]
    julia> block(t, first(blocksectors(t)))5×2 Matrix{Float64}: + -2.28774 -0.760859 + -0.178306 -0.0913147 + -0.470114 -0.195959 + 1.16939 -0.0388692 + 0.426774 -1.11967
    julia> fusiontrees(t)TensorKit.TensorKeyIterator{SU2Irrep, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}(TensorKit.SortedVectorDict{SU2Irrep, Dict{FusionTree{SU2Irrep, 2, 0, 1, Nothing}, UnitRange{Int64}}}(0 => Dict(FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()) => 1:4, FusionTree{Irrep[SU₂]}((1, 1), 0, (false, false), ()) => 5:5), 1 => Dict(FusionTree{Irrep[SU₂]}((1, 1), 1, (false, false), ()) => 5:5, FusionTree{Irrep[SU₂]}((1, 0), 1, (false, false), ()) => 1:2, FusionTree{Irrep[SU₂]}((0, 1), 1, (false, false), ()) => 3:4), 2 => Dict(FusionTree{Irrep[SU₂]}((1, 1), 2, (false, false), ()) => 1:1)), TensorKit.SortedVectorDict{SU2Irrep, Dict{FusionTree{SU2Irrep, 2, 0, 1, Nothing}, UnitRange{Int64}}}(0 => Dict(FusionTree{Irrep[SU₂]}((0, 0), 0, (false, true), ()) => 1:1, FusionTree{Irrep[SU₂]}((1, 1), 0, (false, true), ()) => 2:2), 1 => Dict(FusionTree{Irrep[SU₂]}((0, 1), 1, (false, true), ()) => 2:2, FusionTree{Irrep[SU₂]}((1, 1), 1, (false, true), ()) => 3:3, FusionTree{Irrep[SU₂]}((1, 0), 1, (false, true), ()) => 1:1), 2 => Dict(FusionTree{Irrep[SU₂]}((1, 1), 2, (false, true), ()) => 1:1)))
    julia> f1, f2 = first(fusiontrees(t))(FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()), FusionTree{Irrep[SU₂]}((0, 0), 0, (false, true), ()))
    julia> t[f1,f2]2×2×1×1 StridedViews.StridedView{Float64, 4, Matrix{Float64}, typeof(identity)}: +[:, :, 1, 1] = + -2.28774 -0.470114 + -0.178306 1.16939

    Reading and writing tensors: Dict conversion

    There are no custom or dedicated methods for reading, writing or storing TensorMaps, however, there is the possibility to convert a t::AbstractTensorMap into a Dict, simply as convert(Dict, t). The backward conversion convert(TensorMap, dict) will return a tensor that is equal to t, i.e. t == convert(TensorMap, convert(Dict, t)).

    This conversion relies on that the string represenation of objects such as VectorSpace, FusionTree or Sector should be such that it represents valid code to recreate the object. Hence, we store information about the domain and codomain of the tensor, and the sector associated with each data block, as a String obtained with repr. This provides the flexibility to still change the internal structure of such objects, without this breaking the ability to load older data files. The resulting dictionary can then be stored using any of the provided Julia packages such as JLD.jl, JLD2.jl, BSON.jl, JSON.jl, ...

    Vector space and linear algebra operations

    AbstractTensorMap instances t represent linear maps, i.e. homomorphisms in a 𝕜-linear category, just like matrices. To a large extent, they follow the interface of Matrix in Julia's LinearAlgebra standard library. Many methods from LinearAlgebra are (re)exported by TensorKit.jl, and can then us be used without using LinearAlgebra explicitly. In all of the following methods, the implementation acts directly on the underlying matrix blocks (typically using the same method) and never needs to perform any basis transforms.

    In particular, AbstractTensorMap instances can be composed, provided the domain of the first object coincides with the codomain of the second. Composing tensor maps uses the regular multiplication symbol as in t = t1*t2, which is also used for matrix multiplication. TensorKit.jl also supports (and exports) the mutating method mul!(t, t1, t2). We can then also try to invert a tensor map using inv(t), though this can only exist if the domain and codomain are isomorphic, which can e.g. be checked as fuse(codomain(t)) == fuse(domain(t)). If the inverse is composed with another tensor t2, we can use the syntax t1\t2 or t2/t1. However, this syntax also accepts instances t1 whose domain and codomain are not isomorphic, and then amounts to pinv(t1), the Moore-Penrose pseudoinverse. This, however, is only really justified as minimizing the least squares problem if InnerProductStyle(t) <: EuclideanProduct.

    AbstractTensorMap instances behave themselves as vectors (i.e. they are 𝕜-linear) and so they can be multiplied by scalars and, if they live in the same space, i.e. have the same domain and codomain, they can be added to each other. There is also a zero(t), the additive identity, which produces a zero tensor with the same domain and codomain as t. In addition, TensorMap supports basic Julia methods such as fill! and copyto!, as well as copy(t) to create a copy with independent data. Aside from basic + and * operations, TensorKit.jl reexports a number of efficient in-place methods from LinearAlgebra, such as axpy! (for y ← α * x + y), axpby! (for y ← α * x + β * y), lmul! and rmul! (for y ← α*y and y ← y*α, which is typically the same) and mul!, which can also be used for out-of-place scalar multiplication y ← α*x.

    For t::AbstractTensorMap{S} where InnerProductStyle(S) <: EuclideanProduct, we can compute norm(t), and for two such instances, the inner product dot(t1, t2), provided t1 and t2 have the same domain and codomain. Furthermore, there is normalize(t) and normalize!(t) to return a scaled version of t with unit norm. These operations should also exist for InnerProductStyle(S) <: HasInnerProduct, but require an interface for defining a custom inner product in these spaces. Currently, there is no concrete subtype of HasInnerProduct that is not an EuclideanProduct. In particular, CartesianSpace, ComplexSpace and GradedSpace all have InnerProductStyle(V) <: EuclideanProduct.

    With tensors that have InnerProductStyle(t) <: EuclideanProduct there is associated an adjoint operation, given by adjoint(t) or simply t', such that domain(t') == codomain(t) and codomain(t') == domain(t). Note that for an instance t::TensorMap{S,N₁,N₂}, t' is simply stored in a wrapper called AdjointTensorMap{S,N₂,N₁}, which is another subtype of AbstractTensorMap. This should be mostly unvisible to the user, as all methods should work for this type as well. It can be hard to reason about the index order of t', i.e. index i of t appears in t' at index position j = TensorKit.adjointtensorindex(t, i), where the latter method is typically not necessary and hence unexported. There is also a plural TensorKit.adjointtensorindices to convert multiple indices at once. Note that, because the adjoint interchanges domain and codomain, we have space(t', j) == space(t, i)'.

    AbstractTensorMap instances can furthermore be tested for exact (t1 == t2) or approximate (t1 ≈ t2) equality, though the latter requires that norm can be computed.

    When tensor map instances are endomorphisms, i.e. they have the same domain and codomain, there is a multiplicative identity which can be obtained as one(t) or one!(t), where the latter overwrites the contents of t. The multiplicative identity on a space V can also be obtained using id(A, V) as discussed above, such that for a general homomorphism t′, we have t′ == id(codomain(t′))*t′ == t′*id(domain(t′)). Returning to the case of endomorphisms t, we can compute the trace via tr(t) and exponentiate them using exp(t), or if the contents of t can be destroyed in the process, exp!(t). Furthermore, there are a number of tensor factorizations for both endomorphisms and general homomorphism that we discuss below.

    Finally, there are a number of operations that also belong in this paragraph because of their analogy to common matrix operations. The tensor product of two TensorMap instances t1 and t2 is obtained as t1 ⊗ t2 and results in a new TensorMap with codomain(t1⊗t2) = codomain(t1) ⊗ codomain(t2) and domain(t1⊗t2) = domain(t1) ⊗ domain(t2). If we have two TensorMap{S,N,1} instances t1 and t2 with the same codomain, we can combine them in a way that is analoguous to hcat, i.e. we stack them such that the new tensor catdomain(t1, t2) has also the same codomain, but has a domain which is domain(t1) ⊕ domain(t2). Similarly, if t1 and t2 are of type TensorMap{S,1,N} and have the same domain, the operation catcodomain(t1, t2) results in a new tensor with the same domain and a codomain given by codomain(t1) ⊕ codomain(t2), which is the analogy of vcat. Note that direct sum only makes sense between ElementarySpace objects, i.e. there is no way to give a tensor product meaning to a direct sum of tensor product spaces.

    Time for some more examples:

    julia> t == t + zero(t) == t*id(domain(t)) == id(codomain(t))*ttrue
    julia> t2 = TensorMap(randn, ComplexF64, codomain(t), domain(t));
    julia> dot(t2, t)9.08481379870156 - 3.2111437888949137im
    julia> tr(t2'*t)9.08481379870156 - 3.211143788894913im
    julia> dot(t2, t) ≈ dot(t', t2')true
    julia> dot(t2, t2)49.12541552970464 + 0.0im
    julia> norm(t2)^249.12541552970464
    julia> t3 = copyto!(similar(t, ComplexF64), t);ERROR: MethodError: no method matching copyto!(::TensorMap{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 2, 2, SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Matrix{ComplexF64}}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}, ::TensorMap{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 2, 2, SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Matrix{Float64}}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}, FusionTree{SU2Irrep, 2, 0, 1, Nothing}}) Closest candidates are: copyto!(!Matched::AbstractArray, ::Any) @@ -690,44 +683,44 @@ p1::NTuple{N₁′,Int}, p2::NTuple{N₂′,Int})

    and

    permute(t::AbstractTensorMap{S,N₁,N₂},
             p1::NTuple{N₁′,Int}, p2::NTuple{N₂′,Int}; copy = false)

    both of which return an instance of AbstractTensorMap{S,N₁′,N₂′}.

    In these methods, p1 and p2 specify which of the original tensor indices ranging from 1 to N₁+N₂ make up the new codomain (with N₁′ spaces) and new domain (with N₂′ spaces). Hence, (p1..., p2...) should be a valid permutation of 1:(N₁+N₂). Note that, throughout TensorKit.jl, permutations are always specified using tuples of Ints, for reasons of type stability. For braid, we also need to specify levels or depths for each of the indices of the original tensor, which determine whether indices will braid over or underneath each other (use the braiding or its inverse). We refer to the section on manipulating fusion trees for more details.

    When BraidingStyle(sectortype(t)) isa SymmetricBraiding, we can use the simpler interface of permute, which does not require the argument levels. permute accepts a keyword argument copy. When copy == true, the result will be a tensor with newly allocated data that can independently be modified from that of the input tensor t. When copy takes the default value false, permute can try to return the result in a way that it shares its data with the input tensor t, though this is only possible in specific cases (e.g. when sectortype(S) == Trivial and (p1..., p2...) = (1:(N₁+N₂)...)).

    Both braid and permute come in a version where the result is stored in an already existing tensor, i.e. braid!(tdst, tsrc, levels, p1, p2) and permute!(tdst, tsrc, p1, p2).

    Another operation that belongs und index manipulations is taking the transpose of a tensor, i.e. LinearAlgebra.transpose(t) and LinearAlgebra.transpose!(tdst, tsrc), both of which are reexported by TensorKit.jl. Note that transpose(t) is not simply equal to reshuffling domain and codomain with braid(t, (1:(N₁+N₂)...), reverse(domainind(tsrc)), reverse(codomainind(tsrc)))). Indeed, the graphical representation (where we draw the codomain and domain as a single object), makes clear that this introduces an additional (inverse) twist, which is then compensated in the transpose implementation.

    transpose

    In categorical language, the reason for this extra twist is that we use the left coevaluation $η$, but the right evaluation $\tilde{ϵ}$, when repartitioning the indices between domain and codomain.

    There are a number of other index related manipulations. We can apply a twist (or inverse twist) to one of the tensor map indices via twist(t, i; inv = false) or twist!(t, i; inv = false). Note that the latter method does not store the result in a new destination tensor, but just modifies the tensor t in place. Twisting several indices simultaneously can be obtained by using the defining property

    $θ_{V⊗W} = τ_{W,V} ∘ (θ_W ⊗ θ_V) ∘ τ_{V,W} = (θ_V ⊗ θ_W) ∘ τ_{W,V} ∘ τ_{V,W}.$

    but is currently not implemented explicitly.

    For all sector types I with BraidingStyle(I) == Bosonic(), all twists are 1 and thus have no effect. Let us start with some examples, in which we illustrate that, albeit permute might act highly non-trivial on the fusion trees and on the corresponding data, after conversion to a regular Array (when possible), it just acts like permutedims

    julia> domain(t) → codomain(t)(Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>2, 1=>1)) ← (Rep[SU₂](0=>1, 1=>1) ⊗ Rep[SU₂](0=>1, 1=>1)')
    julia> ta = convert(Array, t);
    julia> t′ = permute(t, (1,2,3,4));
    julia> domain(t′) → codomain(t′)(Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>1, 1=>1)' ⊗ Rep[SU₂](0=>1, 1=>1)) ← ProductSpace{GradedSpace{SU2Irrep, TensorKit.SortedVectorDict{SU2Irrep, Int64}}, 0}()
    julia> convert(Array, t′) ≈ tatrue
    julia> t′′ = permute(t, (4,2,3),(1,));
    julia> domain(t′′) → codomain(t′′)(Rep[SU₂](0=>1, 1=>1) ⊗ Rep[SU₂](0=>2, 1=>1) ⊗ Rep[SU₂](0=>1, 1=>1)') ← Rep[SU₂](0=>2, 1=>1)'
    julia> convert(Array, t′′) ≈ permutedims(ta, (4,2,3,1))true
    julia> mTensorMap(Rep[SU₂](0=>2, 1=>1) ← Rep[SU₂](0=>1, 1=>1)): * Data for fusiontree FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()): - 1.6079185612547917 - 1.3783359056024296 + 0.12502142580250492 + 0.03185341182692353 * Data for fusiontree FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()): - 2.09270183142595
    julia> transpose(m)TensorMap(Rep[SU₂](0=>1, 1=>1)' ← Rep[SU₂](0=>2, 1=>1)'): + 1.6993281003070992
    julia> transpose(m)TensorMap(Rep[SU₂](0=>1, 1=>1)' ← Rep[SU₂](0=>2, 1=>1)'): * Data for fusiontree FusionTree{Irrep[SU₂]}((0,), 0, (true,), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (true,), ()): - 1.6079185612547917 1.3783359056024296 + 0.12502142580250492 0.03185341182692353 * Data for fusiontree FusionTree{Irrep[SU₂]}((1,), 1, (true,), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (true,), ()): - 2.0927018314259493
    julia> convert(Array, transpose(t)) ≈ permutedims(ta,(4,3,2,1))true
    julia> dot(t2, t) ≈ dot(transpose(t2), transpose(t))true
    julia> transpose(transpose(t)) ≈ ttrue
    julia> twist(t, 3) ≈ ttrue
    julia> # as twist acts trivially for + 1.699328100307099
    julia> convert(Array, transpose(t)) ≈ permutedims(ta,(4,3,2,1))true
    julia> dot(t2, t) ≈ dot(transpose(t2), transpose(t))true
    julia> transpose(transpose(t)) ≈ ttrue
    julia> twist(t, 3) ≈ ttrue
    julia> # as twist acts trivially for BraidingStyle(sectortype(t))Bosonic()

    Note that transpose acts like one would expect on a TensorMap{S,1,1}. On a TensorMap{S,N₁,N₂}, because transpose replaces the codomain with the dual of the domain, which has its tensor product operation reversed, this in the end amounts in a complete reversal of all tensor indices when representing it as a plain mutli-dimensional Array. Also, note that we have not defined the conjugation of TensorMap instances. One definition that one could think of is conj(t) = adjoint(transpose(t)). However note that codomain(adjoint(tranpose(t))) == domain(transpose(t)) == dual(codomain(t)) and similarly domain(adjoint(tranpose(t))) == dual(domain(t)), where dual of a ProductSpace is composed of the dual of the ElementarySpace instances, in reverse order of tensor product. This might be very confusing, and as such we leave tensor conjugation undefined. However, note that we have a conjugation syntax within the context of tensor contractions.

    To show the effect of twist, we now consider a type of sector I for which BraidingStyle{I} != Bosonic(). In particular, we use FibonacciAnyon. We cannot convert the resulting TensorMap to an Array, so we have to rely on indirect tests to verify our results.

    julia> V1 = GradedSpace{FibonacciAnyon}(:I=>3,:τ=>2)Vect[FibonacciAnyon](:I=>3, :τ=>2)
    julia> V2 = GradedSpace{FibonacciAnyon}(:I=>2,:τ=>1)Vect[FibonacciAnyon](:I=>2, :τ=>1)
    julia> m = TensorMap(randn, Float32, V1, V2)TensorMap(Vect[FibonacciAnyon](:I=>3, :τ=>2) ← Vect[FibonacciAnyon](:I=>2, :τ=>1)): * Data for fusiontree FusionTree{FibonacciAnyon}((:I,), :I, (false,), ()) ← FusionTree{FibonacciAnyon}((:I,), :I, (false,), ()): - -0.7098672f0 + 0.0f0im -0.6189144f0 + 0.0f0im - -0.24348144f0 + 0.0f0im -1.7643014f0 + 0.0f0im - -0.24532987f0 + 0.0f0im -0.08395435f0 + 0.0f0im + 2.0367117f0 + 0.0f0im 1.0766205f0 + 0.0f0im + -0.20259398f0 + 0.0f0im -0.5631235f0 + 0.0f0im + -0.64117223f0 + 0.0f0im 0.41604647f0 + 0.0f0im * Data for fusiontree FusionTree{FibonacciAnyon}((:τ,), :τ, (false,), ()) ← FusionTree{FibonacciAnyon}((:τ,), :τ, (false,), ()): - 1.0206032f0 + 0.0f0im - -0.043369032f0 + 0.0f0im
    julia> transpose(m)TensorMap(Vect[FibonacciAnyon](:I=>2, :τ=>1)' ← Vect[FibonacciAnyon](:I=>3, :τ=>2)'): + 0.729483f0 + 0.0f0im + 0.35013244f0 + 0.0f0im
    julia> transpose(m)TensorMap(Vect[FibonacciAnyon](:I=>2, :τ=>1)' ← Vect[FibonacciAnyon](:I=>3, :τ=>2)'): * Data for fusiontree FusionTree{FibonacciAnyon}((:I,), :I, (true,), ()) ← FusionTree{FibonacciAnyon}((:I,), :I, (true,), ()): - -0.7098672f0 + 0.0f0im -0.24348144f0 + 0.0f0im -0.24532987f0 + 0.0f0im - -0.6189144f0 + 0.0f0im -1.7643014f0 + 0.0f0im -0.08395435f0 + 0.0f0im + 2.0367117f0 + 0.0f0im -0.20259398f0 + 0.0f0im -0.64117223f0 + 0.0f0im + 1.0766205f0 + 0.0f0im -0.5631235f0 + 0.0f0im 0.41604647f0 + 0.0f0im * Data for fusiontree FusionTree{FibonacciAnyon}((:τ,), :τ, (true,), ()) ← FusionTree{FibonacciAnyon}((:τ,), :τ, (true,), ()): - 1.0206032f0 + 0.0f0im -0.043369032f0 + 0.0f0im
    julia> twist(braid(m, (1,2), (2,), (1,)), 1)ERROR: AssertionError: length(levels) == numind(t)
    julia> t1 = TensorMap(randn, V1*V2', V2*V1);
    julia> t2 = TensorMap(randn, ComplexF64, V1*V2', V2*V1);
    julia> dot(t1, t2) ≈ dot(transpose(t1), transpose(t2))true
    julia> transpose(transpose(t1)) ≈ t1true

    A final operation that one might expect in this section is to fuse or join indices, and its inverse, to split a given index into two or more indices. For a plain tensor (i.e. with sectortype(t) == Trivial) amount to the equivalent of reshape on the multidimensional data. However, this represents only one possibility, as there is no canonically unique way to embed the tensor product of two spaces V₁ ⊗ V₂ in a new space V = fuse(V₁⊗V₂). Such a mapping can always be accompagnied by a basis transform. However, one particular choice is created by the function isomorphism, or for EuclideanProduct spaces, unitary. Hence, we can join or fuse two indices of a tensor by first constructing u = unitary(fuse(space(t, i) ⊗ space(t, j)), space(t, i) ⊗ space(t, j)) and then contracting this map with indices i and j of t, as explained in the section on contracting tensors. Note, however, that a typical algorithm is not expected to often need to fuse and split indices, as e.g. tensor factorizations can easily be applied without needing to reshape or fuse indices first, as explained in the next section.

    Tensor factorizations

    Eigenvalue decomposition

    As tensors are linear maps, they have various kinds of factorizations. Endomorphism, i.e. tensor maps t with codomain(t) == domain(t), have an eigenvalue decomposition. For this, we overload both LinearAlgebra.eigen(t; kwargs...) and LinearAlgebra.eigen!(t; kwargs...), where the latter destroys t in the process. The keyword arguments are the same that are accepted by LinearAlgebra.eigen(!) for matrices. The result is returned as D, V = eigen(t), such that t*V ≈ V*D. For given t::TensorMap{S,N,N}, V is a TensorMap{S,N,1}, whose codomain corresponds to that of t, but whose domain is a single space S (or more correctly a ProductSpace{S,1}), that corresponds to fuse(codomain(t)). The eigenvalues are encoded in D, a TensorMap{S,1,1}, whose domain and codomain correspond to the domain of V. Indeed, we cannot reasonably associate a tensor product structure with the different eigenvalues. Note that D stores the eigenvalues on the diagonal of a (collection of) DenseMatrix instance(s), as there is currently no dedicated DiagonalTensorMap or diagonal storage support.

    We also define LinearAlgebra.ishermitian(t), which can only return true for instances of AbstractEuclideanTensorMap. In all other cases, as the inner product is not defined, there is no notion of hermiticity (i.e. we are not working in a -category). For instances of EuclideanTensorMap, we also define and export the routines eigh and eigh!, which compute the eigenvalue decomposition under the guarantee (not checked) that the map is hermitian. Hence, eigenvalues will be real and V will be unitary with eltype(V) == eltype(t). We also define and export eig and eig!, which similarly assume that the TensorMap is not hermitian (hence this does not require EuclideanTensorMap), and always returns complex values eigenvalues and eigenvectors. Like for matrices, LinearAlgebra.eigen is type unstable and checks hermiticity at run-time, then falling back to either eig or eigh.

    Orthogonal factorizations

    Other factorizations that are provided by TensorKit.jl are orthogonal or unitary in nature, and thus always require a AbstractEuclideanTensorMap. However, they don't require equal domain and codomain. Let us first discuss the singular value decomposition, for which we define and export the methods tsvd and tsvd! (where as always, the latter destroys the input).

    U, Σ, Vʰ, ϵ = tsvd(t; trunc = notrunc(), p::Real = 2,
    + 0.729483f0 + 0.0f0im  0.35013244f0 + 0.0f0im
    julia> twist(braid(m, (1,2), (2,), (1,)), 1)ERROR: AssertionError: length(levels) == numind(t)
    julia> t1 = TensorMap(randn, V1*V2', V2*V1);
    julia> t2 = TensorMap(randn, ComplexF64, V1*V2', V2*V1);
    julia> dot(t1, t2) ≈ dot(transpose(t1), transpose(t2))true
    julia> transpose(transpose(t1)) ≈ t1true

    A final operation that one might expect in this section is to fuse or join indices, and its inverse, to split a given index into two or more indices. For a plain tensor (i.e. with sectortype(t) == Trivial) amount to the equivalent of reshape on the multidimensional data. However, this represents only one possibility, as there is no canonically unique way to embed the tensor product of two spaces V₁ ⊗ V₂ in a new space V = fuse(V₁⊗V₂). Such a mapping can always be accompagnied by a basis transform. However, one particular choice is created by the function isomorphism, or for EuclideanProduct spaces, unitary. Hence, we can join or fuse two indices of a tensor by first constructing u = unitary(fuse(space(t, i) ⊗ space(t, j)), space(t, i) ⊗ space(t, j)) and then contracting this map with indices i and j of t, as explained in the section on contracting tensors. Note, however, that a typical algorithm is not expected to often need to fuse and split indices, as e.g. tensor factorizations can easily be applied without needing to reshape or fuse indices first, as explained in the next section.

    Tensor factorizations

    Eigenvalue decomposition

    As tensors are linear maps, they have various kinds of factorizations. Endomorphism, i.e. tensor maps t with codomain(t) == domain(t), have an eigenvalue decomposition. For this, we overload both LinearAlgebra.eigen(t; kwargs...) and LinearAlgebra.eigen!(t; kwargs...), where the latter destroys t in the process. The keyword arguments are the same that are accepted by LinearAlgebra.eigen(!) for matrices. The result is returned as D, V = eigen(t), such that t*V ≈ V*D. For given t::TensorMap{S,N,N}, V is a TensorMap{S,N,1}, whose codomain corresponds to that of t, but whose domain is a single space S (or more correctly a ProductSpace{S,1}), that corresponds to fuse(codomain(t)). The eigenvalues are encoded in D, a TensorMap{S,1,1}, whose domain and codomain correspond to the domain of V. Indeed, we cannot reasonably associate a tensor product structure with the different eigenvalues. Note that D stores the eigenvalues on the diagonal of a (collection of) DenseMatrix instance(s), as there is currently no dedicated DiagonalTensorMap or diagonal storage support.

    We also define LinearAlgebra.ishermitian(t), which can only return true for instances of AbstractEuclideanTensorMap. In all other cases, as the inner product is not defined, there is no notion of hermiticity (i.e. we are not working in a -category). For instances of EuclideanTensorMap, we also define and export the routines eigh and eigh!, which compute the eigenvalue decomposition under the guarantee (not checked) that the map is hermitian. Hence, eigenvalues will be real and V will be unitary with eltype(V) == eltype(t). We also define and export eig and eig!, which similarly assume that the TensorMap is not hermitian (hence this does not require EuclideanTensorMap), and always returns complex values eigenvalues and eigenvectors. Like for matrices, LinearAlgebra.eigen is type unstable and checks hermiticity at run-time, then falling back to either eig or eigh.

    Orthogonal factorizations

    Other factorizations that are provided by TensorKit.jl are orthogonal or unitary in nature, and thus always require a AbstractEuclideanTensorMap. However, they don't require equal domain and codomain. Let us first discuss the singular value decomposition, for which we define and export the methods tsvd and tsvd! (where as always, the latter destroys the input).

    U, Σ, Vʰ, ϵ = tsvd(t; trunc = notrunc(), p::Real = 2,
                             alg::OrthogonalFactorizationAlgorithm = SDD())

    This computes a (possibly truncated) singular value decomposition of t::TensorMap{S,N₁,N₂} (with InnerProductStyle(t)<:EuclideanProduct), such that norm(t - U*Σ*Vʰ) ≈ ϵ, where U::TensorMap{S,N₁,1}, S::TensorMap{S,1,1}, Vʰ::TensorMap{S,1,N₂} and ϵ::Real. U is an isometry, i.e. U'*U approximates the identity, whereas U*U' is an idempotent (squares to itself). The same holds for adjoint(Vʰ). The domain of U equals the domain and codomain of Σ and the codomain of . In the case of trunc = notrunc() (default value, see below), this space is given by min(fuse(codomain(t)), fuse(domain(t))). The singular values are contained in Σ and are stored on the diagonal of a (collection of) DenseMatrix instance(s), similar to the eigenvalues before.

    The keyword argument trunc provides a way to control the truncation, and is connected to the keyword argument p. The default value notrunc() implies no truncation, and thus ϵ = 0. Other valid options are

    Furthermore, the alg keyword can be either SVD() or SDD() (default), which corresponds to two different algorithms in LAPACK to compute singular value decompositions. The default value SDD() uses a divide-and-conquer algorithm and is typically the fastest, but can loose some accuracy. The SVD() method uses a QR-iteration scheme and can be more accurate, but is typically slower. Since Julia 1.3, these two algorithms are also available in the LinearAlgebra standard library, where they are specified as LinearAlgebra.DivideAndConquer() and LinearAlgebra.QRIteration().

    Note that we defined the new method tsvd (truncated or tensor singular value decomposition), rather than overloading LinearAlgebra.svd. We (will) also support LinearAlgebra.svd(t) as alternative for tsvd(t; trunc = notrunc()), but note that the return values are then given by U, Σ, V = svd(t) with V = adjoint(Vʰ).

    We also define the following pair of orthogonal factorization algorithms, which are useful when one is not interested in truncating a tensor or knowing the singular values, but only in its image or coimage.

    Furthermore, we can compute an orthonormal basis for the orthogonal complement of the image and of the co-image (i.e. the kernel) with the following methods:

    Note that the methods leftorth, rightorth, leftnull and rightnull also come in a form with exclamation mark, i.e. leftorth!, rightorth!, leftnull! and rightnull!, which destroy the input tensor t.

    Factorizations for custom index bipartions

    Finally, note that each of the factorizations take a single argument, the tensor map t, and a number of keyword arguments. They perform the factorization according to the given codomain and domain of the tensor map. In many cases, we want to perform the factorization according to a different bipartition of the indices. When BraidingStyle(sectortype(t)) isa SymmetricBraiding, we can immediately specify an alternative bipartition of the indices of t in all of these methods, in the form

    factorize(t::AbstracTensorMap, pleft::NTuple{N₁′,Int}, pright::NTuple{N₂′,Int}; kwargs...)

    where pleft will be the indices in the codomain of the new tensor map, and pright the indices of the domain. Here, factorize is any of the methods LinearAlgebra.eigen, eig, eigh, tsvd, LinearAlgebra.svd, leftorth, rightorth, leftnull and rightnull. This signature does not allow for the exclamation mark, because it amounts to

    factorize!(permute(t, pleft, pright; copy = true); kwargs...)

    where permute was introduced and discussed in the previous section. When the braiding is not symmetric, the user should manually apply braid to bring the tensor map in proper form before performing the factorization.

    Some examples to conclude this section

    julia> V1 = SU₂Space(0=>2,1/2=>1)Rep[SU₂](0=>2, 1/2=>1)
    julia> V2 = SU₂Space(0=>1,1/2=>1,1=>1)Rep[SU₂](0=>1, 1/2=>1, 1=>1)
    julia> t = TensorMap(randn, V1 ⊗ V1, V2);
    julia> U, S, W = tsvd(t);
    julia> t ≈ U * S * Wtrue
    julia> D, V = eigh(t'*t);
    julia> D ≈ S*Strue
    julia> U'*U ≈ id(domain(U))true
    julia> STensorMap(Rep[SU₂](0=>1, 1/2=>1, 1=>1) ← Rep[SU₂](0=>1, 1/2=>1, 1=>1)): * Data for fusiontree FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()): - 2.337812255916377 + 2.5910272257669833 * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()): - 1.2140365646185858 + 1.585204913187908 * Data for fusiontree FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()): - 0.07958172336891368
    julia> Q, R = leftorth(t; alg = Polar());
    julia> isposdef(R)true
    julia> Q ≈ U*Wtrue
    julia> R ≈ W'*S*Wtrue
    julia> U2, S2, W2, ε = tsvd(t; trunc = truncspace(V1));
    julia> W2*W2' ≈ id(codomain(W2))true
    julia> S2TensorMap(Rep[SU₂](0=>1, 1/2=>1) ← Rep[SU₂](0=>1, 1/2=>1)): + 0.5096927987956277
    julia> Q, R = leftorth(t; alg = Polar());
    julia> isposdef(R)true
    julia> Q ≈ U*Wtrue
    julia> R ≈ W'*S*Wtrue
    julia> U2, S2, W2, ε = tsvd(t; trunc = truncspace(V1));
    julia> W2*W2' ≈ id(codomain(W2))true
    julia> S2TensorMap(Rep[SU₂](0=>1, 1/2=>1) ← Rep[SU₂](0=>1, 1/2=>1)): * Data for fusiontree FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()): - 2.337812255916377 + 2.5910272257669833 * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()): - 1.2140365646185858
    julia> ε ≈ norm(block(S, Irrep[SU₂](1)))*sqrt(dim(Irrep[SU₂](1)))true
    julia> L, Q = rightorth(t, (1,), (2,3));
    julia> codomain(L), domain(L), domain(Q)(ProductSpace(Rep[SU₂](0=>2, 1/2=>1)), ProductSpace(Rep[SU₂](0=>2, 1/2=>1)), (Rep[SU₂](0=>2, 1/2=>1)' ⊗ Rep[SU₂](0=>1, 1/2=>1, 1=>1)))
    julia> Q*Q'TensorMap(Rep[SU₂](0=>2, 1/2=>1) ← Rep[SU₂](0=>2, 1/2=>1)): + 1.585204913187908
    julia> ε ≈ norm(block(S, Irrep[SU₂](1)))*sqrt(dim(Irrep[SU₂](1)))true
    julia> L, Q = rightorth(t, (1,), (2,3));
    julia> codomain(L), domain(L), domain(Q)(ProductSpace(Rep[SU₂](0=>2, 1/2=>1)), ProductSpace(Rep[SU₂](0=>2, 1/2=>1)), (Rep[SU₂](0=>2, 1/2=>1)' ⊗ Rep[SU₂](0=>1, 1/2=>1, 1=>1)))
    julia> Q*Q'TensorMap(Rep[SU₂](0=>2, 1/2=>1) ← Rep[SU₂](0=>2, 1/2=>1)): * Data for fusiontree FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()): - 1.0 1.4064886207516121e-16 - 1.4064886207516121e-16 0.9999999999999992 + 1.0 -1.0277015966149416e-16 + -1.0277015966149416e-16 0.9999999999999997 * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()): - 0.9999999999999994
    julia> P = Q'*Q;
    julia> P ≈ P*Ptrue
    julia> t′ = permute(t, (1,), (2,3));
    julia> t′ ≈ t′ * Ptrue

    Bosonic tensor contractions and tensor networks

    One of the most important operation with tensor maps is to compose them, more generally known as contracting them. As mentioned in the section on category theory, a typical composition of maps in a ribbon category can graphically be represented as a planar arrangement of the morphisms (i.e. tensor maps, boxes with lines eminating from top and bottom, corresponding to source and target, i.e. domain and codomain), where the lines connecting the source and targets of the different morphisms should be thought of as ribbons, that can braid over or underneath each other, and that can twist. Technically, we can embed this diagram in $ℝ × [0,1]$ and attach all the unconnected line endings corresponding objects in the source at some position $(x,0)$ for $x∈ℝ$, and all line endings corresponding to objects in the target at some position $(x,1)$. The resulting morphism is then invariant under what is known as framed three-dimensional isotopy, i.e. three-dimensional rearrangements of the morphism that respect the rules of boxes connected by ribbons whose open endings are kept fixed. Such a two-dimensional diagram cannot easily be encoded in a single line of code.

    However, things simplify when the braiding is symmetric (such that over- and under- crossings become equivalent, i.e. just crossings), and when twists, i.e. self-crossings in this case, are trivial. This amounts to BraidingStyle(I) == Bosonic() in the language of TensorKit.jl, and is true for any subcategory of $\mathbf{Vect}$, i.e. ordinary tensors, possibly with some symmetry constraint. The case of $\mathbf{SVect}$ and its subcategories, and more general categories, are discussed below.

    In the case of triival twists, we can deform the diagram such that we first combine every morphism with a number of coevaluations $η$ so as to represent it as a tensor, i.e. with a trivial domain. We can then rearrange the morphism to be all ligned up horizontally, where the original morphism compositions are now being performed by evaluations $ϵ$. This process will generate a number of crossings and twists, where the latter can be omitted because they act trivially. Similarly, double crossings can also be omitted. As a consequence, the diagram, or the morphism it represents, is completely specified by the tensors it is composed of, and which indices between the different tensors are connect, via the evaluation $ϵ$, and which indices make up the source and target of the resulting morphism. If we also compose the resulting morphisms with coevaluations so that it has a trivial domain, we just have one type of unconnected lines, henceforth called open indices. We sketch such a rearrangement in the following picture

    tensor unitary

    Hence, we can now specify such a tensor diagram, henceforth called a tensor contraction or also tensor network, using a one-dimensional syntax that mimicks abstract index notation and specifies which indices are connected by the evaluation map using Einstein's summation conventation. Indeed, for BraidingStyle(I) == Bosonic(), such a tensor contraction can take the same format as if all tensors were just multi-dimensional arrays. For this, we rely on the interface provided by the package TensorOperations.jl.

    The above picture would be encoded as

    @tensor E[a,b,c,d,e] := A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]

    or

    @tensor E[:] := A[1,2,-4,3]*B[4,5,-3,3]*C[1,-5,4,-2]*D[-1,2,5]

    where the latter syntax is known as NCON-style, and labels the unconnected or outgoing indices with negative integers, and the contracted indices with positive integers.

    A number of remarks are in order. TensorOperations.jl accepts both integers and any valid variable name as dummy label for indices, and everything in between [ ] is not resolved in the current context but interpreted as a dummy label. Here, we label the indices of a TensorMap, like A::TensorMap{S,N₁,N₂}, in a linear fashion, where the first position corresponds to the first space in codomain(A), and so forth, up to position N₁. Index N₁+1then corresponds to the first space in domain(A). However, because we have applied the coevaluation $η$, it actually corresponds to the corresponding dual space, in accordance with the interface of space(A, i) that we introduced above, and as indiated by the dotted box around $A$ in the above picture. The same holds for the other tensor maps. Note that our convention also requires that we braid indices that we brought from the domain to the codomain, and so this is only unambiguous for a symmetric braiding, where there is a unique way to permute the indices.

    With the current syntax, we create a new object E because we use the definition operator :=. Furthermore, with the current syntax, it will be a Tensor, i.e. it will have a trivial domain, and correspond to the dotted box in the picture above, rather than the actual morphism E. We can also directly define E with the correct codomain and domain by rather using

    @tensor E[a b c;d e] := A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]

    or

    @tensor E[(a,b,c);(d,e)] := A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]

    where the latter syntax can also be used when the codomain is empty. When using the assignment operator =, the TensorMap E is assumed to exist and the contents will be written to the currently allocated memory. Note that for existing tensors, both on the left hand side and right hand side, trying to specify the indices in the domain and the codomain seperately using the above syntax, has no effect, as the bipartition of indices are already fixed by the existing object. Hence, if E has been created by the previous line of code, all of the following lines are now equivalent

    @tensor E[(a,b,c);(d,e)] = A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]
    + 1.0000000000000002
    julia> P = Q'*Q;
    julia> P ≈ P*Ptrue
    julia> t′ = permute(t, (1,), (2,3));
    julia> t′ ≈ t′ * Ptrue

    Bosonic tensor contractions and tensor networks

    One of the most important operation with tensor maps is to compose them, more generally known as contracting them. As mentioned in the section on category theory, a typical composition of maps in a ribbon category can graphically be represented as a planar arrangement of the morphisms (i.e. tensor maps, boxes with lines eminating from top and bottom, corresponding to source and target, i.e. domain and codomain), where the lines connecting the source and targets of the different morphisms should be thought of as ribbons, that can braid over or underneath each other, and that can twist. Technically, we can embed this diagram in $ℝ × [0,1]$ and attach all the unconnected line endings corresponding objects in the source at some position $(x,0)$ for $x∈ℝ$, and all line endings corresponding to objects in the target at some position $(x,1)$. The resulting morphism is then invariant under what is known as framed three-dimensional isotopy, i.e. three-dimensional rearrangements of the morphism that respect the rules of boxes connected by ribbons whose open endings are kept fixed. Such a two-dimensional diagram cannot easily be encoded in a single line of code.

    However, things simplify when the braiding is symmetric (such that over- and under- crossings become equivalent, i.e. just crossings), and when twists, i.e. self-crossings in this case, are trivial. This amounts to BraidingStyle(I) == Bosonic() in the language of TensorKit.jl, and is true for any subcategory of $\mathbf{Vect}$, i.e. ordinary tensors, possibly with some symmetry constraint. The case of $\mathbf{SVect}$ and its subcategories, and more general categories, are discussed below.

    In the case of triival twists, we can deform the diagram such that we first combine every morphism with a number of coevaluations $η$ so as to represent it as a tensor, i.e. with a trivial domain. We can then rearrange the morphism to be all ligned up horizontally, where the original morphism compositions are now being performed by evaluations $ϵ$. This process will generate a number of crossings and twists, where the latter can be omitted because they act trivially. Similarly, double crossings can also be omitted. As a consequence, the diagram, or the morphism it represents, is completely specified by the tensors it is composed of, and which indices between the different tensors are connect, via the evaluation $ϵ$, and which indices make up the source and target of the resulting morphism. If we also compose the resulting morphisms with coevaluations so that it has a trivial domain, we just have one type of unconnected lines, henceforth called open indices. We sketch such a rearrangement in the following picture

    tensor unitary

    Hence, we can now specify such a tensor diagram, henceforth called a tensor contraction or also tensor network, using a one-dimensional syntax that mimicks abstract index notation and specifies which indices are connected by the evaluation map using Einstein's summation conventation. Indeed, for BraidingStyle(I) == Bosonic(), such a tensor contraction can take the same format as if all tensors were just multi-dimensional arrays. For this, we rely on the interface provided by the package TensorOperations.jl.

    The above picture would be encoded as

    @tensor E[a,b,c,d,e] := A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]

    or

    @tensor E[:] := A[1,2,-4,3]*B[4,5,-3,3]*C[1,-5,4,-2]*D[-1,2,5]

    where the latter syntax is known as NCON-style, and labels the unconnected or outgoing indices with negative integers, and the contracted indices with positive integers.

    A number of remarks are in order. TensorOperations.jl accepts both integers and any valid variable name as dummy label for indices, and everything in between [ ] is not resolved in the current context but interpreted as a dummy label. Here, we label the indices of a TensorMap, like A::TensorMap{S,N₁,N₂}, in a linear fashion, where the first position corresponds to the first space in codomain(A), and so forth, up to position N₁. Index N₁+1then corresponds to the first space in domain(A). However, because we have applied the coevaluation $η$, it actually corresponds to the corresponding dual space, in accordance with the interface of space(A, i) that we introduced above, and as indiated by the dotted box around $A$ in the above picture. The same holds for the other tensor maps. Note that our convention also requires that we braid indices that we brought from the domain to the codomain, and so this is only unambiguous for a symmetric braiding, where there is a unique way to permute the indices.

    With the current syntax, we create a new object E because we use the definition operator :=. Furthermore, with the current syntax, it will be a Tensor, i.e. it will have a trivial domain, and correspond to the dotted box in the picture above, rather than the actual morphism E. We can also directly define E with the correct codomain and domain by rather using

    @tensor E[a b c;d e] := A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]

    or

    @tensor E[(a,b,c);(d,e)] := A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]

    where the latter syntax can also be used when the codomain is empty. When using the assignment operator =, the TensorMap E is assumed to exist and the contents will be written to the currently allocated memory. Note that for existing tensors, both on the left hand side and right hand side, trying to specify the indices in the domain and the codomain seperately using the above syntax, has no effect, as the bipartition of indices are already fixed by the existing object. Hence, if E has been created by the previous line of code, all of the following lines are now equivalent

    @tensor E[(a,b,c);(d,e)] = A[v,w,d,x]*B[y,z,c,x]*C[v,e,y,b]*D[a,w,z]
     @tensor E[a,b,c,d,e] = A[v w d;x]*B[(y,z,c);(x,)]*C[v e y; b]*D[a,w,z]
     @tensor E[a b; c d e] = A[v; w d x]*B[y,z,c,x]*C[v,e,y,b]*D[a w;z]

    and none of those will or can change the partition of the indices of E into its codomain and its domain.

    Two final remarks are in order. Firstly, the order of the tensors appearing on the right hand side is irrelevant, as we can reorder them by using the allowed moves of the Penrose graphical calculus, which yields some crossings and a twist. As the latter is trivial, it can be omitted, and we just use the same rules to evaluate the newly ordered tensor network. For the particular case of matrix matrix multiplication, which also captures more general settings by appropriotely combining spaces into a single line, we indeed find

    tensor contraction reorder

    or thus, the following to lines of code yield the same result

    @tensor C[i,j] := B[i,k]*A[k,j]
     @tensor C[i,j] := A[k,j]*B[i,k]

    Reordering of tensors can be used internally by the @tensor macro to evaluate the contraction in a more efficient manner. In particular, the NCON-style of specifying the contraction gives the user control over the order, and there are other macros, such as @tensoropt, that try to automate this process. There is also an @ncon macro and ncon function, an we recommend reading the manual of TensorOperations.jl to learn more about the possibilities and how they work.

    A final remark involves the use of adjoints of tensors. The current framework is such that the user should not be to worried about the actual bipartition into codomain and domain of a given TensorMap instance. Indeed, for factorizations one just specifies the requested bipartition via the factorize(t, pleft, pright) interface, and for tensor contractions the @contract macro figures out the correct manipulations automatically. However, when wanting to use the adjoint of an instance t::TensorMap{S,N₁,N₂}, the resulting adjoint(t) is a AbstractTensorMap{S,N₂,N₁} and one need to know the values of N₁ and N₂ to know exactly where the ith index of t will end up in adjoint(t), and hence to know and understand the index order of t'. Within the @tensor macro, one can instead use conj() on the whole index expression so as to be able to use the original index ordering of t. Indeed, for matrices of thus, TensorMap{S,1,1} instances, this yields exactly the equivalence one expects, namely equivalence between the following to expressions.

    @tensor C[i,j] := B'[i,k]*A[k,j]
    -@tensor C[i,j] := conj(B[k,i])*A[k,j]

    For e.g. an instance A::TensorMap{S,3,2}, the following two syntaxes have the same effect within an @tensor expression: conj(A[a,b,c,d,e]) and A'[d,e,a,b,c].

    Some examples:

    Fermionic tensor contractions

    TODO

    Anyonic tensor contractions

    TODO

    +@tensor C[i,j] := conj(B[k,i])*A[k,j]

    For e.g. an instance A::TensorMap{S,3,2}, the following two syntaxes have the same effect within an @tensor expression: conj(A[a,b,c,d,e]) and A'[d,e,a,b,c].

    Some examples:

    Fermionic tensor contractions

    TODO

    Anyonic tensor contractions

    TODO

    diff --git a/dev/man/tutorial/index.html b/dev/man/tutorial/index.html index 03e06b72..e550c2ea 100644 --- a/dev/man/tutorial/index.html +++ b/dev/man/tutorial/index.html @@ -1,647 +1,647 @@ Tutorial · TensorKit.jl

    Tutorial

    Before discussing at length all aspects of this package, both its usage and implementation, we start with a short tutorial to sketch the main capabilities. Thereto, we start by loading TensorKit.jl

    julia> using TensorKit

    Cartesian tensors

    The most important objects in TensorKit.jl are tensors, which we now create with random (normally distributed) entries in the following manner

    julia> A = Tensor(randn, ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)TensorMap((ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()):
     [:, :, 1] =
    - -0.17429971238236658   0.18696180911513027
    -  1.1242504123062416   -1.355984001520811
    -  0.4641031558505154   -0.21278763285669525
    + -0.00648284616202221  -0.5193471178322424
    + -0.5526523684610151    0.43540237831136314
    + -0.5228260936859954    1.0846543335787748
     
     [:, :, 2] =
    -  1.7563156648119544  0.05833850429649959
    - -0.7346655972941211  2.281640727199211
    - -0.774481662808094   0.6891360592953527
    + 0.19027725607107435   0.5101326620570305
    + 0.19410342831999508   0.30054253417530424
    + 0.7727805699995111   -2.1223027498887417
     
     [:, :, 3] =
    - -0.6335985391820647   0.27052513409279266
    - -1.6633459485136917   1.0981994425827704
    - -1.148420640875026   -1.2756235665650175
    +  1.068685588236546    0.056231231186049765
    +  1.5530605006156328  -0.3648891856762683
    + -0.3092872218760381  -0.3729831632384705
     
     [:, :, 4] =
    -  1.876284069065462     0.22247668038218493
    - -0.9963087391494874   -0.2559562270287114
    -  0.04185398811321818  -1.164143605161402

    Note that we entered the tensor size not as plain dimensions, by specifying the vector space associated with these tensor indices, in this case ℝ^n, which can be obtained by typing \bbR+TAB. The tensor then lives in the tensor product of the different spaces, which we can obtain by typing (i.e. \otimes+TAB), although for simplicity also the usual multiplication sign * does the job. Note also that A is printed as an instance of a parametric type TensorMap, which we will discuss below and contains Tensor.

    Briefly sidetracking into the nature of ℝ^n:

    julia> V = ℝ^3ℝ^3
    julia> typeof(V)CartesianSpace
    julia> V == CartesianSpace(3)true
    julia> supertype(CartesianSpace)ElementarySpace
    julia> supertype(ElementarySpace)VectorSpace

    i.e. ℝ^n can also be created without Unicode using the longer syntax CartesianSpace(n). It is subtype of ElementarySpace{ℝ}, with a standard (Euclidean) inner product over the real numbers. Furthermore,

    julia> W = ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)
    julia> typeof(W)ProductSpace{CartesianSpace, 3}
    julia> supertype(ProductSpace)CompositeSpace
    julia> supertype(CompositeSpace)VectorSpace

    i.e. the tensor product of a number of CartesianSpaces is some generic parametric ProductSpace type, specifically ProductSpace{CartesianSpace,N} for the tensor product of N instances of CartesianSpace.

    Tensors are itself vectors (but not Vectors), so we can compute linear combinations, provided they live in the same space.

    julia> B = Tensor(randn, ℝ^3 * ℝ^2 * ℝ^4);
    julia> C = 0.5*A + 2.5*BTensorMap((ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()): + 0.895358479648683 -1.2891370270003981 + 0.5993267344455467 -0.7411804114884271 + 0.31091448535411703 -1.5752762532907538

    Note that we entered the tensor size not as plain dimensions, by specifying the vector space associated with these tensor indices, in this case ℝ^n, which can be obtained by typing \bbR+TAB. The tensor then lives in the tensor product of the different spaces, which we can obtain by typing (i.e. \otimes+TAB), although for simplicity also the usual multiplication sign * does the job. Note also that A is printed as an instance of a parametric type TensorMap, which we will discuss below and contains Tensor.

    Briefly sidetracking into the nature of ℝ^n:

    julia> V = ℝ^3ℝ^3
    julia> typeof(V)CartesianSpace
    julia> V == CartesianSpace(3)true
    julia> supertype(CartesianSpace)ElementarySpace
    julia> supertype(ElementarySpace)VectorSpace

    i.e. ℝ^n can also be created without Unicode using the longer syntax CartesianSpace(n). It is subtype of ElementarySpace{ℝ}, with a standard (Euclidean) inner product over the real numbers. Furthermore,

    julia> W = ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)
    julia> typeof(W)ProductSpace{CartesianSpace, 3}
    julia> supertype(ProductSpace)CompositeSpace
    julia> supertype(CompositeSpace)VectorSpace

    i.e. the tensor product of a number of CartesianSpaces is some generic parametric ProductSpace type, specifically ProductSpace{CartesianSpace,N} for the tensor product of N instances of CartesianSpace.

    Tensors are itself vectors (but not Vectors), so we can compute linear combinations, provided they live in the same space.

    julia> B = Tensor(randn, ℝ^3 * ℝ^2 * ℝ^4);
    julia> C = 0.5*A + 2.5*BTensorMap((ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()): [:, :, 1] = - 0.42225095502576004 -1.1876754299200851 - -1.593181977854715 -3.800663895182666 - -2.0857049596761326 -2.302654301804463 + -1.476010869165645 -0.7054233935745577 + -3.275296095671374 2.345005046206513 + -4.080714460863584 -1.4674065132233252 [:, :, 2] = - -6.130987027357851 3.3944730867927877 - 2.8692542651315676 0.11420211691138449 - 0.3241730670998156 -0.8053861383499183 + 0.9887433485122128 4.3086080607197035 + -2.1428347592406247 1.989141675080263 + 2.6354008093177046 -4.234409365758294 [:, :, 3] = - 1.652873961052998 -0.5709219010894346 - -1.4995423093155331 3.442988262235226 - 0.580063970123016 1.0296614736736422 + 3.7350117032572636 1.4365602210059625 + 2.9965305458791023 0.40278892041036773 + 1.4253086080560817 -0.260973930625305 [:, :, 4] = - -5.738441082349442 0.9261766821789179 - -1.8080683032715679 0.7392029325369515 - -1.546603605694117 2.009051539416347

    Given that they are behave as vectors, they also have a scalar product and norm, which they inherit from the Euclidean inner product on the individual ℝ^n spaces:

    julia> scalarBA = dot(B,A)-12.900222861628832
    julia> scalarAA = dot(A,A)26.71557615726044
    julia> normA² = norm(A)^226.71557615726044

    If two tensors live on different spaces, these operations have no meaning and are thus not allowed

    julia> B′ = Tensor(randn, ℝ^4 * ℝ^2 * ℝ^3);
    julia> space(B′) == space(A)false
    julia> C′ = 0.5*A + 2.5*B′ERROR: SpaceMismatch("(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}() ≠ (ℝ^4 ⊗ ℝ^2 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}()")
    julia> scalarBA′ = dot(B′,A)ERROR: SpaceMismatch("(ℝ^4 ⊗ ℝ^2 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}() ≠ (ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()")

    However, in this particular case, we can reorder the indices of B′ to match space of A, using the routine permute (we deliberately choose not to overload permutedims from Julia Base, for reasons that become clear below):

    julia> space(permute(B′,(3,2,1))) == space(A)true

    We can contract two tensors using Einstein summation convention, which takes the interface from TensorOperations.jl. TensorKit.jl reexports the @tensor macro

    julia> @tensor D[a,b,c,d] := A[a,b,e]*B[d,c,e]TensorMap((ℝ^3 ⊗ ℝ^2 ⊗ ℝ^2 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}()):
    +  3.2306742449996007    -0.1631707353353828
    +  0.031496786803818455   1.6371837743911977
    + -1.491988403898421     -0.5729193297033844

    Given that they are behave as vectors, they also have a scalar product and norm, which they inherit from the Euclidean inner product on the individual ℝ^n spaces:

    julia> scalarBA = dot(B,A)7.645989536422615
    julia> scalarAA = dot(A,A)17.615798979232103
    julia> normA² = norm(A)^217.615798979232103

    If two tensors live on different spaces, these operations have no meaning and are thus not allowed

    julia> B′ = Tensor(randn, ℝ^4 * ℝ^2 * ℝ^3);
    julia> space(B′) == space(A)false
    julia> C′ = 0.5*A + 2.5*B′ERROR: SpaceMismatch("(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}() ≠ (ℝ^4 ⊗ ℝ^2 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}()")
    julia> scalarBA′ = dot(B′,A)ERROR: SpaceMismatch("(ℝ^4 ⊗ ℝ^2 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}() ≠ (ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()")

    However, in this particular case, we can reorder the indices of B′ to match space of A, using the routine permute (we deliberately choose not to overload permutedims from Julia Base, for reasons that become clear below):

    julia> space(permute(B′,(3,2,1))) == space(A)true

    We can contract two tensors using Einstein summation convention, which takes the interface from TensorOperations.jl. TensorKit.jl reexports the @tensor macro

    julia> @tensor D[a,b,c,d] := A[a,b,e]*B[d,c,e]TensorMap((ℝ^3 ⊗ ℝ^2 ⊗ ℝ^2 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}()):
     [:, :, 1, 1] =
    - -10.469683179448554   -0.5064809854348049
    -   3.639104714351682   -5.124433062897527
    -   1.2493654662679161   0.12851651516925167
    + 2.4367469218371114  -0.8747795327239427
    + 3.0504548116581565  -1.4413087789070382
    + 0.5343640505461087  -3.6286908306113475
     
     [:, :, 2, 1] =
    -  3.2441337192002186  -0.021174553892757415
    - -1.420005842813604    3.3726087395919113
    - -0.9423398274111233   1.0175546948566487
    + 1.084157823879317    0.7031815195609656
    + 1.4036261163060715   0.061380942894193095
    + 1.2318430225909913  -4.147995144827885
     
     [:, :, 1, 2] =
    -  1.610211348930322   -0.27449729078926083
    - -0.9539750825562148   3.9636471273770897
    - -1.1179169557300694   2.0263797443498883
    +  0.690247803412969    0.35416157946662336
    +  1.8038774201773375  -1.0360936290144382
    + -0.3731982480358491   0.4381140898590773
     
     [:, :, 2, 2] =
    - -0.5861081863096599   0.13283415454193265
    - -3.3735847568159762   1.9392102087074665
    - -1.576500488696414   -1.8976197533757606
    + 1.1036849246207745  -1.0888514596659251
    + 0.517394884589687   -0.08911047746531421
    + 0.3008296490634128  -1.9905325184278755
     
     [:, :, 1, 3] =
    - -0.8076110097663736  -0.17132317183208237
    - -1.3946412355812063   2.573949723870071
    - -1.2071419881008763   0.5343448535970892
    + 0.2664452928301445   2.1373850994916097
    + 1.6054759160255951  -0.13698505325984336
    + 1.093579330382257   -2.7639266484072604
     
     [:, :, 2, 3] =
    -  0.8673199518751936   0.21994180248720266
    - -2.7917834826328063   0.6089263456615518
    - -0.774073946795475   -2.1874582663378974
    julia> @tensor d = A[a,b,c]*A[a,b,c]26.715576157260443
    julia> d ≈ scalarAA ≈ normA²true

    We hope that the index convention is clear. The := is to create a new tensor D, without the : the result would be written in an existing tensor D, which in this case would yield an error as no tensor D exists. If the contraction yields a scalar, regular assignment with = can be used.

    Finally, we can factorize a tensor, creating a bipartition of a subset of its indices and its complement. With a plain Julia Array, one would apply permutedims and reshape to cast the array into a matrix before applying e.g. the singular value decomposition. With TensorKit.jl, one just specifies which indices go to the left (rows) and right (columns)

    julia> U, S, Vd = tsvd(A, (1,3), (2,));
    julia> @tensor A′[a,b,c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> A ≈ A′true
    julia> UTensorMap((ℝ^3 ⊗ ℝ^4) ← ℝ^2): + -0.1912471785609365 -0.3424093350559221 + 0.20310197777400846 -0.7842837539187678 + -0.5246781146305987 1.6977148219302567
    julia> @tensor d = A[a,b,c]*A[a,b,c]17.615798979232103
    julia> d ≈ scalarAA ≈ normA²true

    We hope that the index convention is clear. The := is to create a new tensor D, without the : the result would be written in an existing tensor D, which in this case would yield an error as no tensor D exists. If the contraction yields a scalar, regular assignment with = can be used.

    Finally, we can factorize a tensor, creating a bipartition of a subset of its indices and its complement. With a plain Julia Array, one would apply permutedims and reshape to cast the array into a matrix before applying e.g. the singular value decomposition. With TensorKit.jl, one just specifies which indices go to the left (rows) and right (columns)

    julia> U, S, Vd = tsvd(A, (1,3), (2,));
    julia> @tensor A′[a,b,c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> A ≈ A′true
    julia> UTensorMap((ℝ^3 ⊗ ℝ^4) ← ℝ^2): [:, :, 1] = - -0.06007943527402654 0.33928928664055386 … 0.34052336697760055 - 0.40807744148042435 -0.45786265562088974 -0.16193618142976832 - 0.12092145017527105 -0.24755542817282947 0.16776874775984338 + 0.11765675252154974 -0.09087971502956343 … 0.41441132644331935 + -0.17356156036077997 -0.04253272732268442 0.24961315670687792 + -0.3177317958455736 0.5881032031533773 0.4012543319813669 [:, :, 2] = - 0.017713463508766705 0.34125553456438146 … 0.4074226018667769 - -0.1544101001037968 0.4743498041257912 -0.25322265046298076 - 0.02910894526619597 0.040813500486177615 -0.3037642743882904

    Note that the tsvd routine returns the decomposition of the linear map as three factors, U, S and Vd, each of them a TensorMap, such that Vd is already what is commonly called V'. Furthermore, observe that U is printed differently then A, i.e. as a TensorMap((ℝ^3 ⊗ ℝ^4) ← ProductSpace(ℝ^2)). What this means is that tensors (or more appropriately, TensorMap instances) in TensorKit.jl are always considered to be linear maps between two ProductSpace instances, with

    julia> codomain(U)(ℝ^3 ⊗ ℝ^4)
    julia> domain(U)ProductSpace(ℝ^2)
    julia> codomain(A)(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)
    julia> domain(A)ProductSpace{CartesianSpace, 0}()

    Hence, a Tensor instance such as A is just a specific case of TensorMap with an empty domain, i.e. a ProductSpace{CartesianSpace,0} instance. In particular, we can represent a vector v and matrix m as

    julia> v = Tensor(randn, ℝ^3)TensorMap(ℝ^3 ← ProductSpace{CartesianSpace, 0}()):
    -  2.04540341370806
    -  0.12459995520191507
    - -1.4063378457004807
    julia> m1 = TensorMap(randn, ℝ^4, ℝ^3)TensorMap(ℝ^4 ← ℝ^3): - 0.7074597499585487 -1.754683440297568 -0.6870627683254862 - 0.031755979900500046 -0.7504042551068201 -0.8006976218473205 - 1.42416139807997 0.056047201829636295 0.3245096368505315 - 2.111342700962773 -0.2777001008903007 -1.034730286640953
    julia> m2 = TensorMap(randn, ℝ^4 → ℝ^2) # alternative syntax for TensorMap(randn, ℝ^2, ℝ^4)TensorMap(ℝ^2 ← ℝ^4): - -1.6335660381944987 1.8650292128297166 … -1.5932126670421505 - -1.6988965302654477 -2.039218923422547 0.11938529399268549
    julia> w = m1 * v # matrix vector productTensorMap(ℝ^4 ← ProductSpace{CartesianSpace, 0}()): - 2.1946494830395196 - 1.09750482169075 - 2.463597880543758 - 5.7391265101220315
    julia> m3 = m2*m1 # matrix matrix productTensorMap(ℝ^2 ← ℝ^3): - -5.743242568534358 1.8588101254212033 0.985246006238839 - 0.6558368123447127 4.543849917202715 3.0571395769718843

    Note that for the construction of m1, in accordance with how one specifies the dimensions of a matrix (e.g. randn(4,3)), the first space is the codomain and the second the domain. This is somewhat opposite to the general notation for a function f:domain→codomain, so that we also support this more mathemical notation, as illustrated in the construction of m2. In fact, there is a third syntax which mixes both and reads as TensorMap(randn, codomain←domain).

    This 'matrix vector' or 'matrix matrix' product can be computed between any two TensorMap instances for which the domain of the first matches with the codomain of the second, e.g.

    julia> v′ = v ⊗ vTensorMap((ℝ^3 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}()):
    -  4.183675124808586    0.2548571737178684    -2.8765282304226023
    -  0.2548571737178684   0.015525148836319242  -0.17522963257303764
    - -2.8765282304226023  -0.17522963257303764    1.977786136249469
    julia> m1′ = m1 ⊗ m1TensorMap((ℝ^4 ⊗ ℝ^4) ← (ℝ^3 ⊗ ℝ^3)): + 0.146871418424024 -0.23084505715524917 … -0.06451761178448134 + 0.13960029866062543 -0.17460586089143482 -0.07689614925946132 + -0.05423427729762492 0.22391193823464905 0.2898612058060877

    Note that the tsvd routine returns the decomposition of the linear map as three factors, U, S and Vd, each of them a TensorMap, such that Vd is already what is commonly called V'. Furthermore, observe that U is printed differently then A, i.e. as a TensorMap((ℝ^3 ⊗ ℝ^4) ← ProductSpace(ℝ^2)). What this means is that tensors (or more appropriately, TensorMap instances) in TensorKit.jl are always considered to be linear maps between two ProductSpace instances, with

    julia> codomain(U)(ℝ^3 ⊗ ℝ^4)
    julia> domain(U)ProductSpace(ℝ^2)
    julia> codomain(A)(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)
    julia> domain(A)ProductSpace{CartesianSpace, 0}()

    Hence, a Tensor instance such as A is just a specific case of TensorMap with an empty domain, i.e. a ProductSpace{CartesianSpace,0} instance. In particular, we can represent a vector v and matrix m as

    julia> v = Tensor(randn, ℝ^3)TensorMap(ℝ^3 ← ProductSpace{CartesianSpace, 0}()):
    + -1.7978562621242844
    +  0.7284786770042588
    + -1.1515246610663286
    julia> m1 = TensorMap(randn, ℝ^4, ℝ^3)TensorMap(ℝ^4 ← ℝ^3): + 0.39385535197907323 1.170219940502845 -0.9465738211153668 + -0.08116023266440886 1.0022867791945806 0.21462835509598677 + 1.5075794495559152 -0.9302258053262665 1.5073438257070717 + 0.45829098705392696 1.1939906784290752 -0.13064754580974516
    julia> m2 = TensorMap(randn, ℝ^4 → ℝ^2) # alternative syntax for TensorMap(randn, ℝ^2, ℝ^4)TensorMap(ℝ^2 ← ℝ^4): + 1.0100646098022485 1.0346278141702545 … 1.3117336863652092 + 1.141643550530372 -0.5060125695856603 -0.7759178387045202
    julia> w = m1 * v # matrix vector productTensorMap(ℝ^4 ← ProductSpace{CartesianSpace, 0}()): + 1.2343880616689065 + 0.6289091355605694 + -5.123804406021042 + 0.1962992997351227
    julia> m3 = m2*m1 # matrix matrix productTensorMap(ℝ^2 ← ℝ^3): + 0.33618415575198474 4.142340361644951 -1.4841448612247548 + -1.1849425679299435 0.7168839566554315 -2.407733402707593

    Note that for the construction of m1, in accordance with how one specifies the dimensions of a matrix (e.g. randn(4,3)), the first space is the codomain and the second the domain. This is somewhat opposite to the general notation for a function f:domain→codomain, so that we also support this more mathemical notation, as illustrated in the construction of m2. In fact, there is a third syntax which mixes both and reads as TensorMap(randn, codomain←domain).

    This 'matrix vector' or 'matrix matrix' product can be computed between any two TensorMap instances for which the domain of the first matches with the codomain of the second, e.g.

    julia> v′ = v ⊗ vTensorMap((ℝ^3 ⊗ ℝ^3) ← ProductSpace{CartesianSpace, 0}()):
    +  3.2322871392595034  -1.3096999512761207   2.070275822888643
    + -1.3096999512761207   0.5306811828498753  -0.8388611616313766
    +  2.070275822888643   -0.8388611616313766   1.3260090450439228
    julia> m1′ = m1 ⊗ m1TensorMap((ℝ^4 ⊗ ℝ^4) ← (ℝ^3 ⊗ ℝ^3)): [:, :, 1, 1] = - 0.5004992978114122 0.02246607760009646 … 1.4936899792999303 - 0.02246607760009646 0.0010084422594409629 0.06704775637484131 - 1.0075368665862727 0.045225640732495576 3.0068927728290835 - 1.4936899792999303 0.06704775637484131 4.457768000908779 + 0.15512203828255966 -0.03196539200274423 … 0.18050035801496128 + -0.03196539200274423 0.006586983366140979 -0.0371950031372983 + 0.5937682347412624 -0.12235549888603951 0.6909100739991962 + 0.18050035801496128 -0.0371950031372983 0.21003062881486265 [:, :, 2, 1] = - -1.2413679079293234 -0.05572169206182984 … -3.704738074172518 - -0.5308808066857019 -0.023829822442421888 -1.5843605467911914 - 0.0396511393922708 0.0017798338147811995 0.11833485049238998 - -0.1964616439393159 -0.008818638822239225 -0.5863200810713621 + 0.46089738655967816 -0.0949753226397416 … 0.5363012516032365 + 0.3947560122036532 -0.08134582819589316 0.45933899734818573 + -0.36637441197679355 0.07549734279071689 -0.4263141025060088 + 0.47025961891241586 -0.09690456126043913 0.5471951665504488 [:, :, 3, 1] = - -0.4860692542853767 -0.02181835146132606 … -1.450624961007292 - -0.5664613393445099 -0.025426937585761696 -1.6905470795655908 - 0.22957750654541645 0.010305121505344048 0.6851510531564499 - -0.732030029861546 -0.032858874185008755 -2.184670238164494 + -0.3728131654895691 0.07682415155576171 … -0.43380625079836876 + 0.08453252634101939 -0.01741928723596965 0.09836224070670051 + 0.5936754330273415 -0.1223363755996461 0.6908020897129363 + -0.051456235140099275 0.010603385214952932 -0.05987459272532125 [:, :, 1, 2] = - -1.2413679079293234 -0.5308808066857019 … -0.1964616439393159 - -0.05572169206182984 -0.023829822442421888 -0.008818638822239225 - -2.498952421521956 -1.0686967730780874 -0.3954897639308794 - -3.704738074172518 -1.5843605467911914 -0.5863200810713621 + 0.46089738655967816 0.3947560122036532 … 0.47025961891241586 + -0.0949753226397416 -0.08134582819589316 -0.09690456126043913 + 1.764199533762635 1.511026950875337 1.800035809760999 + 0.5363012516032365 0.45933899734818573 0.5471951665504488 [:, :, 2, 2] = - 3.0789139756545088 1.3167219199647688 … 0.4872757684011746 - 1.3167219199647688 0.5631065460824215 0.2083873373516749 - -0.09834509692547835 -0.04205805873978983 -0.015564313602709047 - 0.4872757684011746 0.2083873373516749 0.0771173460344832 + 1.3694147091504822 1.1728959751158703 … 1.3972317006722241 + 1.1728959751158703 1.0045787877482462 1.1967210714710301 + -1.0885687865631148 -0.9323530263441486 -1.1106809403937419 + 1.3972317006722241 1.1967210714710301 1.4256137401755233 [:, :, 3, 2] = - 1.205577662025735 0.5155748248769162 … 0.19079740008195684 - 1.4049708577411375 0.6008469024881409 0.22235381036962476 - -0.5694116859986051 -0.2435134123158078 -0.09011635889326745 - 1.8156240991432357 0.7764660099832706 0.2873447049944424 + -1.1076995606271753 -0.9487384264356281 … -1.1302003188567389 + 0.25116238093064913 0.21511916275298734 0.2562642553111737 + 1.7639238020362602 1.5107907882067781 1.7997544770818643 + -0.1528863632843227 -0.1309463078993259 -0.15599195185647133 [:, :, 1, 3] = - -0.4860692542853767 -0.5664613393445099 … -0.732030029861546 - -0.02181835146132606 -0.025426937585761696 -0.032858874185008755 - -0.978488272707119 -1.1403226445693873 -1.4736229316582676 - -1.450624961007292 -1.6905470795655908 -2.184670238164494 + -0.3728131654895691 0.08453252634101939 … -0.051456235140099275 + 0.07682415155576171 -0.01741928723596965 0.010603385214952932 + -1.427035240201144 0.32356929743469925 -0.19696155519768682 + -0.43380625079836876 0.09836224070670051 -0.05987459272532125 [:, :, 2, 3] = - 1.205577662025735 1.4049708577411375 … 1.8156240991432357 - 0.5155748248769162 0.6008469024881409 0.7764660099832706 - -0.03850794564596717 -0.04487686121618657 -0.0579937372146029 - 0.19079740008195684 0.22235381036962476 0.2873447049944424 + -1.1076995606271753 0.25116238093064913 … -0.1528863632843227 + -0.9487384264356281 0.21511916275298734 -0.1309463078993259 + 0.8805273950478034 -0.1996528344650162 0.12153171851477049 + -1.1302003188567389 0.2562642553111737 -0.15599195185647133 [:, :, 3, 3] = - 0.4720552476190807 0.5501295246580533 … 0.7109246552097569 - 0.5501295246580533 0.6411166816319547 0.8285060797668072 - -0.2229584894428244 -0.2598340944927582 -0.335779949556102 - 0.7109246552097569 0.8285060797668072 1.0706667660920686
    julia> w′ = m1′ * v′TensorMap((ℝ^4 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()): - 4.816486353405631 2.4086383895569843 … 12.595371028537718 - 2.4086383895569843 1.204516833634445 6.298719017152138 - 5.406733814952615 2.703810552603887 14.138899906509135 - 12.595371028537722 6.298719017152137 32.93757309918549
    julia> w′ ≈ w ⊗ wtrue

    Another example involves checking that U from the singular value decomposition is a unitary, or at least a left isometric tensor

    julia> codomain(U)(ℝ^3 ⊗ ℝ^4)
    julia> domain(U)ProductSpace(ℝ^2)
    julia> space(U)(ℝ^3 ⊗ ℝ^4) ← ℝ^2
    julia> U'*U # should be the identity on the corresponding domain = codomainTensorMap(ℝ^2 ← ℝ^2): - 0.9999999999999997 -2.1934881761124523e-16 - -2.1934881761124523e-16 1.0
    julia> U'*U ≈ one(U'*U)true
    julia> P = U*U' # should be a projectorTensorMap((ℝ^3 ⊗ ℝ^4) ← (ℝ^3 ⊗ ℝ^4)): + 0.8960019988209464 -0.203161582202914 … 0.1236675466564754 + -0.203161582202914 0.04606533081120899 -0.02804066785447318 + -1.4268122048341982 0.3235187258756006 -0.1969307715201012 + 0.1236675466564754 -0.02804066785447318 0.017068781226109463
    julia> w′ = m1′ * v′TensorMap((ℝ^4 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()): + 1.5237138867907203 0.7763179288104789 … 0.24230951210700158 + 0.7763179288104789 0.3955267007915428 0.1234544229075612 + -6.324762989118917 -3.22240739977213 -1.0057992168816667 + 0.24230951210700136 0.12345442290756126 0.038533415076499655
    julia> w′ ≈ w ⊗ wtrue

    Another example involves checking that U from the singular value decomposition is a unitary, or at least a left isometric tensor

    julia> codomain(U)(ℝ^3 ⊗ ℝ^4)
    julia> domain(U)ProductSpace(ℝ^2)
    julia> space(U)(ℝ^3 ⊗ ℝ^4) ← ℝ^2
    julia> U'*U # should be the identity on the corresponding domain = codomainTensorMap(ℝ^2 ← ℝ^2): + 1.0 1.4211481854992335e-16 + 1.4211481854992335e-16 1.0
    julia> U'*U ≈ one(U'*U)true
    julia> P = U*U' # should be a projectorTensorMap((ℝ^3 ⊗ ℝ^4) ← (ℝ^3 ⊗ ℝ^4)): [:, :, 1, 1] = - 0.003923305332322354 -0.014339491277220947 … -0.013241586194810402 - -0.027252199905787127 0.035910507728541985 0.005243584152163588 - -0.006749272199295173 0.015595938775170374 -0.015460169011685974 + 0.03541432496380193 -0.04459715312102864 … 0.039282497721351485 + 8.260432208112712e-5 -0.030648873026944485 0.018074826891701402 + -0.04534875650593423 0.10208057700114295 0.08978260807896948 [:, :, 2, 1] = - -0.027252199905787127 0.0857630027609347 … 0.07604973962172049 - 0.19036967725927373 -0.26008782179448514 -0.02698236779443206 - 0.044850600855157956 -0.10732380244901625 0.11536691336246468 + 8.260432208112712e-5 -0.016452813777527872 … -0.08093255432266694 + 0.049611858621004486 -0.01699298380781523 -0.05405797436709845 + 0.04757490495479892 -0.0708139361412364 -0.0291776170595496 [:, :, 3, 1] = - -0.006749272199295173 0.05096094124693002 … 0.053036221571448626 - 0.044850600855157956 -0.04155759381345027 -0.02695260216682136 - 0.01546932780700095 -0.028746723421644683 0.011444582636215039 + -0.04534875650593423 0.04139508990482101 … -0.12817258892148203 + 0.04757490495479892 0.022983622511823214 -0.07513962946510172 + 0.10389485092524893 -0.1990027890289234 -0.14321167250476696 [:, :, 1, 2] = - -0.014339491277220947 0.23157255989987766 … 0.25457114805992775 - 0.0857630027609347 0.0065266021724952605 -0.1413568424261554 - 0.05096094124693002 -0.070065071702902 -0.04673910108992121 + -0.04459715312102864 0.06154856301686491 … -0.022768011472283477 + -0.016452813777527872 0.04417226207564044 -0.004933676578331907 + 0.04139508990482101 -0.10513561569007256 -0.10337890596624022 [:, :, 2, 2] = - 0.035910507728541985 0.0065266021724952605 … 0.03734789828659488 - -0.26008782179448514 0.43464594808638995 -0.045971584576788675 - -0.04155759381345027 0.13270626171788436 -0.22090556843601172 + -0.030648873026944485 0.04417226207564044 … -0.006360890798756917 + -0.01699298380781523 0.03229623955114491 0.002809790010316378 + 0.022983622511823214 -0.06410996991665055 -0.06767790646801068 [:, :, 3, 2] = - 0.015595938775170374 -0.070065071702902 … -0.067670065355624 - -0.10732380244901625 0.13270626171788436 0.029753277962737242 - -0.028746723421644683 0.06294943183976816 -0.05392974754613733 + 0.10208057700114295 -0.10513561569007256 … 0.22927036499942213 + -0.0708139361412364 -0.06410996991665055 0.12958033118507398 + -0.1990027890289234 0.39600193364325986 0.3008823423284841 [:, :, 1, 3] = - 0.008955079434931604 -0.07046800144856973 … -0.07365149840775626 - -0.05928839518447891 0.05294634539909397 0.037706355846430256 - -0.02094356671340343 0.03834970373899381 -0.013541447420335112 + -0.060808986896814396 0.10786243147452718 … 0.08760097238141462 + -0.09508118416416064 0.08500816995112553 0.0724929018316805 + -0.013376986064361825 -0.03931110796524475 -0.09792681580786779 [:, :, 2, 3] = - 0.02854214313459907 -0.1675985700190287 … -0.16915143879972735 - -0.19337140154656113 0.21258806481452064 0.08130415487913657 - -0.05838743922123004 0.11807444708478852 -0.07600788818346839 + -0.05821351695541935 0.1189373901253588 … 0.16156558370016783 + -0.1386013636090953 0.0976078358148958 0.12128172258353069 + -0.058532643634823085 0.03050694818521624 -0.0655643815792226 [:, :, 3, 3] = - -0.006675332425381061 -0.20690402995276416 … -0.24364426506011042 - 0.06423931565227238 -0.23897385462654094 0.14883017947062888 - -0.02246075040480182 -0.009671655322418999 0.15959638996961592 + 0.04168516731707438 -0.0614179759101545 … 0.0020113174091880423 + 0.02717770617688816 -0.04531247306946478 -0.00825514991748649 + -0.027352247246693138 0.08137238445391448 0.08963960271795403 [:, :, 1, 4] = - -0.013241586194810402 0.25457114805992775 … 0.2819493399696558 - 0.07604973962172049 0.03734789828659488 -0.1583116848391893 - 0.053036221571448626 -0.067670065355624 -0.06663125216465318 + 0.039282497721351485 -0.022768011472283477 … 0.17589926971488445 + -0.08093255432266694 -0.006360890798756917 0.10840367527424487 + -0.12817258892148203 0.22927036499942213 0.14758318720994748 [:, :, 2, 4] = - 0.005243584152163588 -0.1413568424261554 … -0.1583116848391893 - -0.02698236779443206 -0.045971584576788675 0.09034503756355176 - -0.02695260216682136 0.029753277962737242 0.049752164301084006 + 0.018074826891701402 -0.004933676578331907 … 0.10840367527424487 + -0.05405797436709845 0.002809790010316378 0.06821974577210575 + -0.07513962946510172 0.12958033118507398 0.07786914990198619 [:, :, 3, 4] = - -0.015460169011685974 -0.04673910108992121 … -0.06663125216465318 - 0.11536691336246468 -0.22090556843601172 0.049752164301084006 - 0.011444582636215039 -0.05392974754613733 0.12041908711955053
    julia> P*P ≈ Ptrue

    Here, the adjoint of a TensorMap results in a new tensor map (actually a simple wrapper of type AdjointTensorMap <: AbstractTensorMap) with domain and codomain interchanged.

    Our original tensor A living in ℝ^4 * ℝ^2 * ℝ^3 is isomorphic to e.g. a linear map ℝ^3 → ℝ^4 * ℝ^2. This is where the full power of permute emerges. It allows to specify a permutation where some indices go to the codomain, and others go to the domain, as in

    julia> A2 = permute(A,(1,2),(3,))TensorMap((ℝ^3 ⊗ ℝ^2) ← ℝ^4):
    +  0.08978260807896948  -0.10337890596624022  …  0.14758318720994748
    + -0.0291776170595496   -0.06767790646801068     0.07786914990198619
    + -0.14321167250476696   0.3008823423284841      0.24502455756517214
    julia> P*P ≈ Ptrue

    Here, the adjoint of a TensorMap results in a new tensor map (actually a simple wrapper of type AdjointTensorMap <: AbstractTensorMap) with domain and codomain interchanged.

    Our original tensor A living in ℝ^4 * ℝ^2 * ℝ^3 is isomorphic to e.g. a linear map ℝ^3 → ℝ^4 * ℝ^2. This is where the full power of permute emerges. It allows to specify a permutation where some indices go to the codomain, and others go to the domain, as in

    julia> A2 = permute(A,(1,2),(3,))TensorMap((ℝ^3 ⊗ ℝ^2) ← ℝ^4):
     [:, :, 1] =
    - -0.17429971238236658   0.18696180911513027
    -  1.1242504123062416   -1.355984001520811
    -  0.4641031558505154   -0.21278763285669525
    + -0.00648284616202221  -0.5193471178322424
    + -0.5526523684610151    0.43540237831136314
    + -0.5228260936859954    1.0846543335787748
     
     [:, :, 2] =
    -  1.7563156648119544  0.05833850429649959
    - -0.7346655972941211  2.281640727199211
    - -0.774481662808094   0.6891360592953527
    + 0.19027725607107435   0.5101326620570305
    + 0.19410342831999508   0.30054253417530424
    + 0.7727805699995111   -2.1223027498887417
     
     [:, :, 3] =
    - -0.6335985391820647   0.27052513409279266
    - -1.6633459485136917   1.0981994425827704
    - -1.148420640875026   -1.2756235665650175
    +  1.068685588236546    0.056231231186049765
    +  1.5530605006156328  -0.3648891856762683
    + -0.3092872218760381  -0.3729831632384705
     
     [:, :, 4] =
    -  1.876284069065462     0.22247668038218493
    - -0.9963087391494874   -0.2559562270287114
    -  0.04185398811321818  -1.164143605161402
    julia> codomain(A2)(ℝ^3 ⊗ ℝ^2)
    julia> domain(A2)ProductSpace(ℝ^4)

    In fact, tsvd(A, (1,3),(2,)) is a shorthand for tsvd(permute(A,(1,3),(2,))), where tsvd(A::TensorMap) will just compute the singular value decomposition according to the given codomain and domain of A.

    Note, finally, that the @tensor macro treats all indices at the same footing and thus does not distinguish between codomain and domain. The linear numbering is first all indices in the codomain, followed by all indices in the domain. However, when @tensor creates a new tensor (i.e. when using :=), the default syntax always creates a Tensor, i.e. with all indices in the codomain.

    julia> @tensor A′[a,b,c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> codomain(A′)(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)
    julia> domain(A′)ProductSpace{CartesianSpace, 0}()
    julia> @tensor A2′[(a,b);(c,)] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> codomain(A2′)(ℝ^3 ⊗ ℝ^2)
    julia> domain(A2′)ProductSpace(ℝ^4)
    julia> @tensor A2′′[a b; c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> A2 ≈ A2′ == A2′′true

    As illustrated for A2′ and A2′′, additional syntax is available that enables one to immediately specify the desired codomain and domain indices.

    Complex tensors

    For applications in e.g. quantum physics, we of course want to work with complex tensors. Trying to create a complex-valued tensor with CartesianSpace indices is of course somewhat contrived and prints a (one-time) warning

    julia> A = Tensor(randn, ComplexF64, ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)┌ Warning: scalartype(data) = ComplexF64 ⊈ ℝ)
    + 0.895358479648683    -1.2891370270003981
    + 0.5993267344455467   -0.7411804114884271
    + 0.31091448535411703  -1.5752762532907538
    julia> codomain(A2)(ℝ^3 ⊗ ℝ^2)
    julia> domain(A2)ProductSpace(ℝ^4)

    In fact, tsvd(A, (1,3),(2,)) is a shorthand for tsvd(permute(A,(1,3),(2,))), where tsvd(A::TensorMap) will just compute the singular value decomposition according to the given codomain and domain of A.

    Note, finally, that the @tensor macro treats all indices at the same footing and thus does not distinguish between codomain and domain. The linear numbering is first all indices in the codomain, followed by all indices in the domain. However, when @tensor creates a new tensor (i.e. when using :=), the default syntax always creates a Tensor, i.e. with all indices in the codomain.

    julia> @tensor A′[a,b,c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> codomain(A′)(ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)
    julia> domain(A′)ProductSpace{CartesianSpace, 0}()
    julia> @tensor A2′[(a,b);(c,)] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> codomain(A2′)(ℝ^3 ⊗ ℝ^2)
    julia> domain(A2′)ProductSpace(ℝ^4)
    julia> @tensor A2′′[a b; c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> A2 ≈ A2′ == A2′′true

    As illustrated for A2′ and A2′′, additional syntax is available that enables one to immediately specify the desired codomain and domain indices.

    Complex tensors

    For applications in e.g. quantum physics, we of course want to work with complex tensors. Trying to create a complex-valued tensor with CartesianSpace indices is of course somewhat contrived and prints a (one-time) warning

    julia> A = Tensor(randn, ComplexF64, ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4)┌ Warning: scalartype(data) = ComplexF64 ⊈ ℝ)
     └ @ TensorKit ~/work/TensorKit.jl/TensorKit.jl/src/tensors/tensor.jl:33
     TensorMap((ℝ^3 ⊗ ℝ^2 ⊗ ℝ^4) ← ProductSpace{CartesianSpace, 0}()):
     [:, :, 1] =
    - -0.03601610886692057 + 0.14805930238147602im  …     0.913834888764014 + 0.21362103057912302im
    -   0.3678790829633049 - 0.37547672181684943im       0.9702594099878935 + 1.2721726047302464im
    -    1.387566558864434 + 0.9624122626383345im      0.033896153726167326 - 0.022134380687265563im
    + -0.8709725671168872 + 0.1565591427809761im   …  -0.30042969839732053 + 0.22706681735290593im
    +  0.9427525488708713 + 0.23222728722366137im       0.0928100554405593 - 0.6317196225232968im
    + -0.8813383600560779 - 0.6109151770889226im        0.6582932858618722 + 0.6508552855035835im
     
     [:, :, 2] =
    -  0.5258212210659451 + 1.0370969676723565im  …   0.41176532910567226 - 1.5374328159735222im
    - -0.3174832091369678 - 0.5696910519934335im     -0.20938281138579473 - 0.6917796603933029im
    - 0.16022907047885568 - 0.4319331521178865im      -0.5418779902613045 - 0.00869147640400947im
    + -0.6947025533001264 + 0.4145361372463529im   …  -0.06713777500784517 + 0.6576804226671858im
    +  1.5844103222640813 + 0.27195072728067776im       0.2500654301030172 + 0.20078004716320022im
    +  0.3335540951314588 + 0.8359425685206592im       -0.9984043591374285 + 0.7669402751249983im
     
     [:, :, 3] =
    - 0.24652548476105224 + 0.4113464118387078im  …  -0.4112509795340461 - 0.46947377593713624im
    - 0.10875921603238423 - 0.441565022202618im       0.6092508933262422 - 0.03374584211181403im
    - 0.12927173932388025 - 1.4149936336139564im      0.3723403137761906 + 0.2270425989008115im
    + -0.22852867767495164 - 0.6160737190685279im   …   -0.1630080576529907 - 0.9072304308379806im
    + -0.13313060543056904 + 1.09121353229946im        -0.25967964444794117 + 1.410045837869086im
    +  -0.9695235820345258 - 0.04154070642373947im      -0.5389632954457658 - 1.6424194653859414im
     
     [:, :, 4] =
    -  0.6409479247120761 - 0.17470903852227246im  …   -0.131749454223472 + 0.5510883524949685im
    -  1.1575438017643724 - 0.42338379398266024im     -0.0874579552852069 - 0.3199253646634578im
    - 0.13648076662430378 + 0.6136712386079771im      -1.1056380728545463 + 1.1138356418864426im

    although most of the above operations will work in the expected way (at your own risk). Indeed, we instead want to work with complex vector spaces

    julia> A = Tensor(randn, ComplexF64, ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4)TensorMap((ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4) ← ProductSpace{ComplexSpace, 0}()):
    + 0.35887098957414715 - 0.3863174797025797im   …   -0.8831701437403813 - 0.7149646067875536im
    + 0.04224737559132809 + 0.42733240633773667im     -0.27456444761009297 + 0.07393270042985725im
    +  -1.000632657171116 - 0.5521290801072543im      -0.43769920484367003 + 0.609056896913538im

    although most of the above operations will work in the expected way (at your own risk). Indeed, we instead want to work with complex vector spaces

    julia> A = Tensor(randn, ComplexF64, ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4)TensorMap((ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4) ← ProductSpace{ComplexSpace, 0}()):
     [:, :, 1] =
    - -0.7935480908212675 - 0.19712595081235465im  …  0.43707144262299485 + 0.29011007092002794im
    -  0.8407280373704293 + 1.4356592632306504im      0.10031304651681584 - 0.43131470208547135im
    - -0.4934596224423919 - 0.1335234828517202im      -0.7024215112871778 - 0.5647015983367872im
    + -0.2855831956511286 + 0.6669663977290862im   …  0.9757480179962746 - 0.06524686863515777im
    + -0.6284768202132675 - 1.3684196457385112im      1.0471486410634745 - 0.2562774970421135im
    + -0.3612960578215699 - 0.32918495082695026im     0.3031577708566112 - 0.6929521476070144im
     
     [:, :, 2] =
    -  -0.5104567733436363 + 0.6452017684710418im  …    -1.520244460813206 + 0.295375146306076im
    - -0.14948893555395043 + 0.7708996501902446im     -0.04404197478643968 - 0.42466188831504337im
    -   1.1608268464624734 - 0.598788413422479im       0.15561345367262464 - 0.27752439555500735im
    + 0.3150914098968857 + 0.35538200999636427im  …   0.7820362197606908 + 0.9006474398554078im
    + 0.5186927819842335 - 0.44047797539339817im     -0.4261700791199269 + 0.5206903191131782im
    +  1.362695136276944 - 0.34565603794332417im     -0.5773753387359369 - 0.2369862166375982im
     
     [:, :, 3] =
    - -0.057672070989493264 + 1.2169175829676877im   …    -0.6166637013848875 + 0.3784196207738239im
    -    1.2943616228401806 + 0.08785759566688768im      -0.43944045268909776 + 1.5334736177518342im
    -   -0.6077847544548622 - 1.0405742128634181im      -0.020488358647961745 - 0.5071827536977945im
    + -0.011724662024337215 - 0.31219710632149744im  …   -0.9697125354762512 + 1.8139762730709248im
    +   0.27472867714359295 + 0.30849711723684037im       0.5044791468932458 - 0.21517117685966936im
    +    1.0013540919741006 + 1.1576495469073376im      -0.05270667736077562 + 0.6560032397324645im
     
     [:, :, 4] =
    -   -0.7041269153376796 - 0.950940599367537im    …   0.7696580821583557 + 0.8176716164946787im
    -   -0.5466525693600319 - 0.38101111592680387im     -0.5187866805320343 + 1.0841417944574157im
    - -0.013950445420674851 + 0.5469264384392388im       1.0626593215562241 - 0.17003988148727534im

    where is obtained as \bbC+TAB and we also have the non-Unicode alternative ℂ^n == ComplexSpace(n). Most functionality works exactly the same

    julia> B = Tensor(randn, ℂ^3 * ℂ^2 * ℂ^4);
    julia> C = im*A + (2.5-0.8im)*BTensorMap((ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4) ← ProductSpace{ComplexSpace, 0}()): + 0.30337474013904203 - 0.894707609041159im … -0.156469486657702 - 0.8528323429865413im + 1.7612144539176056 - 0.06028092247299408im -0.5781791503379602 + 0.4894526822459764im + 0.2270692692904872 - 0.33787749265620637im -0.04004912811832454 + 1.1219050684223109im

    where is obtained as \bbC+TAB and we also have the non-Unicode alternative ℂ^n == ComplexSpace(n). Most functionality works exactly the same

    julia> B = Tensor(randn, ℂ^3 * ℂ^2 * ℂ^4);
    julia> C = im*A + (2.5-0.8im)*BTensorMap((ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4) ← ProductSpace{ComplexSpace, 0}()): [:, :, 1] = - 0.31438586833750026 - 0.8310712644293141im … 1.2316831422469332 - 0.04990238559043275im - -3.467471422384122 + 1.4909079282995403im 0.7415511198045013 + 0.0010373928467262844im - 1.2850703151955187 - 0.8619546087924075im 2.601049888909564 - 1.3540529642704664im + -1.9174487907632933 + 0.11457117011981771im … 3.038465311971936 + 0.02431811612850565im + 5.010646802738833 - 1.7939895104533705im -1.3492182381994247 + 1.5609072763407668im + 4.128882001915797 - 1.5771991141700008im -1.1023734518620674 + 0.8776619626867174im [:, :, 2] = - -0.7778444476983646 - 0.46801111599089296im … -2.9110539916938643 - 0.6832272302891137im - 1.9845662752821225 - 1.031238031705108im -0.6310469170311147 + 0.29378484292433094im - 5.10427592912979 - 0.28092915856386624im -0.3261645322594637 + 0.3487939105732554im + 0.80998030570658 - 0.05782453112805647im … 4.594353538541592 - 0.9763640933263492im + -4.05605693877566 + 1.9575839545183324im -2.6776586848526245 + 0.264059797916696im + 2.676251931642508 + 0.616904450293205im -0.9175323373722162 - 0.20792940145279626im [:, :, 3] = - -1.4830909232160114 + 0.027503397889970298im … -1.9269938817284853 - 0.12111993787939584im - -2.6008053631509758 + 2.0985049084350886im 0.04829826797175696 - 0.9456074561206469im - -0.4133945464124631 - 0.14251475148658022im 3.3009885346413452 - 0.914506208549898im + -0.7182005956610689 + 0.318002602610084im … -4.415549868649929 - 0.1372089848909699im + 0.07408447922774253 + 0.15230256627492642im 0.7115150834913939 + 0.3456490967710939im + -0.7757395225991568 + 0.8791428841954827im 2.670232106614271 - 1.1171019881917312im [:, :, 4] = - 2.4851589052482557 - 1.1950767732195096im … -2.9169683352656013 + 1.441433032165051im - -4.089537274122743 + 0.8839229154558232im -0.8038609434099087 - 0.6084765528672365im - -2.7554689477824024 + 0.6927831575691377im 0.6112167965597232 + 0.9214827087330408im
    julia> scalarBA = dot(B,A)1.4649338187075391 - 2.324966949409743im
    julia> scalarAA = dot(A,A)24.61518477146973 + 0.0im
    julia> normA² = norm(A)^224.61518477146972
    julia> U,S,Vd = tsvd(A,(1,3),(2,));
    julia> @tensor A′[a,b,c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> A′ ≈ Atrue
    julia> permute(A,(1,3),(2,)) ≈ U*S*Vdtrue

    However, trying the following

    julia> @tensor D[a,b,c,d] := A[a,b,e]*B[d,c,e]ERROR: SpaceMismatch("(ℂ^3 ⊗ ℂ^2) ← ((ℂ^3)' ⊗ (ℂ^2)') ≠ (ℂ^3 ⊗ ℂ^2) ← (ℂ^4)' * ℂ^4 ← ((ℂ^3)' ⊗ (ℂ^2)')")
    julia> @tensor d = A[a,b,c]*A[a,b,c]ERROR: SpaceMismatch("ProductSpace{ComplexSpace, 0}() ← ProductSpace{ComplexSpace, 0}() ≠ ProductSpace{ComplexSpace, 0}() ← ((ℂ^3)' ⊗ (ℂ^2)' ⊗ (ℂ^4)') * (ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4) ← ProductSpace{ComplexSpace, 0}()")

    we obtain SpaceMismatch errors. The reason for this is that, with ComplexSpace, an index in a space ℂ^n can only be contracted with an index in the dual space dual(ℂ^n) == (ℂ^n)'. Because of the complex Euclidean inner product, the dual space is equivalent to the complex conjugate space, but not the the space itself.

    julia> dual(ℂ^3) == conj(ℂ^3) == (ℂ^3)'true
    julia> (ℂ^3)' == ℂ^3false
    julia> @tensor d = conj(A[a,b,c])*A[a,b,c]24.61518477146973 - 1.2071128228932625e-16im
    julia> d ≈ normA²true

    This might seem overly strict or puristic, but we believe that it can help to catch errors, e.g. unintended contractions. In particular, contracting two indices both living in ℂ^n would represent an operation that is not invariant under arbitrary unitary basis changes.

    It also makes clear the isomorphism between linear maps ℂ^n → ℂ^m and tensors in ℂ^m ⊗ (ℂ^n)':

    julia> m = TensorMap(randn, ComplexF64, ℂ^3, ℂ^4)TensorMap(ℂ^3 ← ℂ^4):
    -   1.8244279730380135 - 0.10949153439151098im  …  -1.0853548887149318 + 0.11599651753566573im
    -   1.4828036491636294 + 0.3223574319746281im      -0.2954769306431321 - 0.23001576507140714im
    - -0.19747723414902174 + 0.6093732976099301im       0.6269009984708227 + 0.010441050346202824im
    julia> m2 = permute(m, (1,2), ())TensorMap((ℂ^3 ⊗ (ℂ^4)') ← ProductSpace{ComplexSpace, 0}()): - 1.8244279730380135 - 0.10949153439151098im … -1.0853548887149318 + 0.11599651753566573im - 1.4828036491636294 + 0.3223574319746281im -0.2954769306431321 - 0.23001576507140714im - -0.19747723414902174 + 0.6093732976099301im 0.6269009984708227 + 0.010441050346202824im
    julia> codomain(m2)(ℂ^3 ⊗ (ℂ^4)')
    julia> space(m, 1)ℂ^3
    julia> space(m, 2)(ℂ^4)'

    Hence, spaces become their corresponding dual space if they are 'permuted' from the domain to the codomain or vice versa. Also, spaces in the domain are reported as their dual when probing them with space(A, i). Generalizing matrix vector and matrix matrix multiplication to arbitrary tensor contractions require that the two indices to be contracted have spaces which are each others dual. Knowing this, all the other functionality of tensors with CartesianSpace indices remains the same for tensors with ComplexSpace indices.

    Symmetries

    So far, the functionality that we have illustrated seems to be just a convenience (or inconvenience?) wrapper around dense multidimensional arrays, e.g. Julia's Base Array. More power becomes visible when involving symmetries. With symmetries, we imply that there is some symmetry action defined on every vector space associated with each of the indices of a TensorMap, and the TensorMap is then required to be equivariant, i.e. it acts as an intertwiner between the tensor product representation on the domain and that on the codomain. By Schur's lemma, this means that the tensor is block diagonal in some basis corresponding to the irreducible representations that can be coupled to by combining the different representations on the different spaces in the domain or codomain. For Abelian symmetries, this does not require a basis change and it just imposes that the tensor has some block sparsity. Let's clarify all of this with some examples.

    We start with a simple $ℤ₂$ symmetry:

    julia> V1 = ℤ₂Space(0=>3,1=>2)Rep[ℤ₂](0=>3, 1=>2)
    julia> dim(V1)5
    julia> V2 = ℤ₂Space(0=>1,1=>1)Rep[ℤ₂](0=>1, 1=>1)
    julia> dim(V2)2
    julia> A = Tensor(randn, V1*V1*V2')TensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>1, 1=>1)') ← ProductSpace{GradedSpace{Z2Irrep, Tuple{Int64, Int64}}, 0}()): + 2.8971559731733425 - 0.3374087363832568im … 1.7253980918358347 - 0.4356905262894759im + -0.3453297981769755 + 1.8910098845255958im 3.1826648247634335 - 1.7532567525809712im + -1.4570168325365396 + 0.8014354533521658im -1.6646890305571256 + 0.1336417397648162im
    julia> scalarBA = dot(B,A)1.9239520514635107 - 0.9589086635191457im
    julia> scalarAA = dot(A,A)24.979137879341184 + 0.0im
    julia> normA² = norm(A)^224.979137879341195
    julia> U,S,Vd = tsvd(A,(1,3),(2,));
    julia> @tensor A′[a,b,c] := U[a,c,d]*S[d,e]*Vd[e,b];
    julia> A′ ≈ Atrue
    julia> permute(A,(1,3),(2,)) ≈ U*S*Vdtrue

    However, trying the following

    julia> @tensor D[a,b,c,d] := A[a,b,e]*B[d,c,e]ERROR: SpaceMismatch("(ℂ^3 ⊗ ℂ^2) ← ((ℂ^3)' ⊗ (ℂ^2)') ≠ (ℂ^3 ⊗ ℂ^2) ← (ℂ^4)' * ℂ^4 ← ((ℂ^3)' ⊗ (ℂ^2)')")
    julia> @tensor d = A[a,b,c]*A[a,b,c]ERROR: SpaceMismatch("ProductSpace{ComplexSpace, 0}() ← ProductSpace{ComplexSpace, 0}() ≠ ProductSpace{ComplexSpace, 0}() ← ((ℂ^3)' ⊗ (ℂ^2)' ⊗ (ℂ^4)') * (ℂ^3 ⊗ ℂ^2 ⊗ ℂ^4) ← ProductSpace{ComplexSpace, 0}()")

    we obtain SpaceMismatch errors. The reason for this is that, with ComplexSpace, an index in a space ℂ^n can only be contracted with an index in the dual space dual(ℂ^n) == (ℂ^n)'. Because of the complex Euclidean inner product, the dual space is equivalent to the complex conjugate space, but not the the space itself.

    julia> dual(ℂ^3) == conj(ℂ^3) == (ℂ^3)'true
    julia> (ℂ^3)' == ℂ^3false
    julia> @tensor d = conj(A[a,b,c])*A[a,b,c]24.979137879341184 + 0.0im
    julia> d ≈ normA²true

    This might seem overly strict or puristic, but we believe that it can help to catch errors, e.g. unintended contractions. In particular, contracting two indices both living in ℂ^n would represent an operation that is not invariant under arbitrary unitary basis changes.

    It also makes clear the isomorphism between linear maps ℂ^n → ℂ^m and tensors in ℂ^m ⊗ (ℂ^n)':

    julia> m = TensorMap(randn, ComplexF64, ℂ^3, ℂ^4)TensorMap(ℂ^3 ← ℂ^4):
    +  1.0137787337691448 + 1.02025385186292im     …     0.9892994466800502 + 0.5102425503420599im
    + 0.21869629932721463 - 0.17591288764918228im     -0.006090938726804035 + 0.254434034205668im
    + -0.6823238483619858 + 0.11319185082949229im        1.0110854220146936 - 0.01474662741471719im
    julia> m2 = permute(m, (1,2), ())TensorMap((ℂ^3 ⊗ (ℂ^4)') ← ProductSpace{ComplexSpace, 0}()): + 1.0137787337691448 + 1.02025385186292im … 0.9892994466800502 + 0.5102425503420599im + 0.21869629932721463 - 0.17591288764918228im -0.006090938726804035 + 0.254434034205668im + -0.6823238483619858 + 0.11319185082949229im 1.0110854220146936 - 0.01474662741471719im
    julia> codomain(m2)(ℂ^3 ⊗ (ℂ^4)')
    julia> space(m, 1)ℂ^3
    julia> space(m, 2)(ℂ^4)'

    Hence, spaces become their corresponding dual space if they are 'permuted' from the domain to the codomain or vice versa. Also, spaces in the domain are reported as their dual when probing them with space(A, i). Generalizing matrix vector and matrix matrix multiplication to arbitrary tensor contractions require that the two indices to be contracted have spaces which are each others dual. Knowing this, all the other functionality of tensors with CartesianSpace indices remains the same for tensors with ComplexSpace indices.

    Symmetries

    So far, the functionality that we have illustrated seems to be just a convenience (or inconvenience?) wrapper around dense multidimensional arrays, e.g. Julia's Base Array. More power becomes visible when involving symmetries. With symmetries, we imply that there is some symmetry action defined on every vector space associated with each of the indices of a TensorMap, and the TensorMap is then required to be equivariant, i.e. it acts as an intertwiner between the tensor product representation on the domain and that on the codomain. By Schur's lemma, this means that the tensor is block diagonal in some basis corresponding to the irreducible representations that can be coupled to by combining the different representations on the different spaces in the domain or codomain. For Abelian symmetries, this does not require a basis change and it just imposes that the tensor has some block sparsity. Let's clarify all of this with some examples.

    We start with a simple $ℤ₂$ symmetry:

    julia> V1 = ℤ₂Space(0=>3,1=>2)Rep[ℤ₂](0=>3, 1=>2)
    julia> dim(V1)5
    julia> V2 = ℤ₂Space(0=>1,1=>1)Rep[ℤ₂](0=>1, 1=>1)
    julia> dim(V2)2
    julia> A = Tensor(randn, V1*V1*V2')TensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>1, 1=>1)') ← ProductSpace{GradedSpace{Z2Irrep, Tuple{Int64, Int64}}, 0}()): * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](1), Irrep[ℤ₂](0)) ← (): [:, :, 1] = - 0.42316687908408396 -0.7803086502377742 - -0.3300788912446799 -0.6518754909757757 + -0.946092487892938 0.032268632003289076 + 0.8690617114170694 -1.0344125667708457 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](1), Irrep[ℤ₂](1)) ← (): [:, :, 1] = - 0.7598503888801573 0.01722729042468152 - -1.9083938297300915 -1.3143038550080517 - -0.472290948093542 0.939813973660034 + 0.22855040738781157 -0.9135788018916902 + -0.2119100499069415 0.6910177520609279 + -2.185629175710066 -0.367165680634526 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](0), Irrep[ℤ₂](1)) ← (): [:, :, 1] = - -0.6028255837687203 -0.30222593255379265 0.09357092181156965 - 0.7612239003549277 -0.07772993064405255 2.035923640166742 + -2.086810630026317 0.4803362574903897 0.09885342496128699 + -0.040435315584946306 1.3729420687628762 0.7174111539294761 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](0), Irrep[ℤ₂](0)) ← (): [:, :, 1] = - 0.5214361167623108 -0.24250498681192728 0.023098179196053236 - 0.400148475560558 0.3544918357709173 -0.8099817801383039 - -1.3647262666062028 -1.0139328600083053 0.9958313713015157
    julia> convert(Array, A)5×5×2 Array{Float64, 3}: + -0.9227192821677203 0.33402980947353594 0.512655755735981 + -0.4403821932370493 0.2611272019748252 1.0947021264578094 + 0.9851977158552763 0.03291100442902132 -0.43413462062077574
    julia> convert(Array, A)5×5×2 Array{Float64, 3}: [:, :, 1] = - 0.521436 -0.242505 0.0230982 0.0 0.0 - 0.400148 0.354492 -0.809982 0.0 0.0 - -1.36473 -1.01393 0.995831 0.0 0.0 - 0.0 0.0 0.0 0.423167 -0.780309 - 0.0 0.0 0.0 -0.330079 -0.651875 + -0.922719 0.33403 0.512656 0.0 0.0 + -0.440382 0.261127 1.0947 0.0 0.0 + 0.985198 0.032911 -0.434135 0.0 0.0 + 0.0 0.0 0.0 -0.946092 0.0322686 + 0.0 0.0 0.0 0.869062 -1.03441 [:, :, 2] = - 0.0 0.0 0.0 0.75985 0.0172273 - 0.0 0.0 0.0 -1.90839 -1.3143 - 0.0 0.0 0.0 -0.472291 0.939814 - -0.602826 -0.302226 0.0935709 0.0 0.0 - 0.761224 -0.0777299 2.03592 0.0 0.0

    Here, we create a 5-dimensional space V1, which has a three-dimensional subspace associated with charge 0 (the trivial irrep of $ℤ₂$) and a two-dimensional subspace with charge 1 (the non-trivial irrep). Similar for V2, where both subspaces are one- dimensional. Representing the tensor as a dense Array, we see that it is zero in those regions where the charges don't add to zero (modulo 2). Of course, the Tensor(Map) type in TensorKit.jl won't store these zero blocks, and only stores the non-zero information, which we can recognize also in the full Array representation.

    From there on, the resulting tensors support all of the same operations as the ones we encountered in the previous examples.

    julia> B = Tensor(randn, V1'*V1*V2);
    julia> @tensor C[a,b] := A[a,c,d]*B[c,b,d]TensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>3, 1=>2)) ← ProductSpace{GradedSpace{Z2Irrep, Tuple{Int64, Int64}}, 0}()): + 0.0 0.0 0.0 0.22855 -0.913579 + 0.0 0.0 0.0 -0.21191 0.691018 + 0.0 0.0 0.0 -2.18563 -0.367166 + -2.08681 0.480336 0.0988534 0.0 0.0 + -0.0404353 1.37294 0.717411 0.0 0.0

    Here, we create a 5-dimensional space V1, which has a three-dimensional subspace associated with charge 0 (the trivial irrep of $ℤ₂$) and a two-dimensional subspace with charge 1 (the non-trivial irrep). Similar for V2, where both subspaces are one- dimensional. Representing the tensor as a dense Array, we see that it is zero in those regions where the charges don't add to zero (modulo 2). Of course, the Tensor(Map) type in TensorKit.jl won't store these zero blocks, and only stores the non-zero information, which we can recognize also in the full Array representation.

    From there on, the resulting tensors support all of the same operations as the ones we encountered in the previous examples.

    julia> B = Tensor(randn, V1'*V1*V2);
    julia> @tensor C[a,b] := A[a,c,d]*B[c,b,d]TensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>3, 1=>2)) ← ProductSpace{GradedSpace{Z2Irrep, Tuple{Int64, Int64}}, 0}()): * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](0)) ← (): - -0.23584777181189892 -0.5300560636491087 0.22113078053268262 - 4.314941377709699 1.7559495894169068 3.2565572039666515 - -4.129356694683361 -1.745275207570574 -4.202317151536617 + 0.1444906098319137 1.5789889640572803 3.1931987128251564 + -0.7314781797209916 -0.09049674501396056 0.8034492731177884 + 0.570853215984137 -3.306502343764754 1.6602875283170646 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](1)) ← (): - -0.4586720275751407 0.011675812571867727 - 1.7748776955144092 2.6350737945521514
    julia> U,S,V = tsvd(A,(1,3),(2,));
    julia> U'*U # should be the identity on the corresponding domain = codomainTensorMap(Rep[ℤ₂](0=>3, 1=>2)' ← Rep[ℤ₂](0=>3, 1=>2)'): + 0.6952520174212404 -1.7830715476761456 + -3.1159589215815755 2.177435303142761
    julia> U,S,V = tsvd(A,(1,3),(2,));
    julia> U'*U # should be the identity on the corresponding domain = codomainTensorMap(Rep[ℤ₂](0=>3, 1=>2)' ← Rep[ℤ₂](0=>3, 1=>2)'): * Data for sector (Irrep[ℤ₂](0),) ← (Irrep[ℤ₂](0),): - 1.0 2.0632929661547972e-16 -1.4648950351367217e-16 - 2.0632929661547972e-16 1.0000000000000002 2.5425018283518267e-16 - -1.4648950351367217e-16 2.5425018283518267e-16 1.0000000000000004 + 1.0000000000000007 2.9206014430144624e-16 8.253683696155952e-17 + 2.9206014430144624e-16 1.0 1.005996055440396e-17 + 8.253683696155952e-17 1.005996055440396e-17 1.0 * Data for sector (Irrep[ℤ₂](1),) ← (Irrep[ℤ₂](1),): - 1.0000000000000002 -1.6114359508245915e-16 - -1.6114359508245915e-16 1.0000000000000002
    julia> U'*U ≈ one(U'*U)true
    julia> P = U*U' # should be a projectorTensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>1, 1=>1)') ← (Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>1, 1=>1)')): + 1.0 -2.074150141699354e-17 + -2.074150141699354e-17 1.0
    julia> U'*U ≈ one(U'*U)true
    julia> P = U*U' # should be a projectorTensorMap((Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>1, 1=>1)') ← (Rep[ℤ₂](0=>3, 1=>2) ⊗ Rep[ℤ₂](0=>1, 1=>1)')): * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](0)): [:, :, 1, 1] = - 0.9759686338155372 - 0.104048255713528 - 0.06763512857580363 + 0.17956134152920086 + 0.237068775760694 + -0.1865038768386907 [:, :, 2, 1] = - 0.104048255713528 - 0.1591054107331896 - -0.27936583036680185 + 0.237068775760694 + 0.7420366968059378 + -0.3042581052805431 [:, :, 3, 1] = - 0.06763512857580363 - -0.27936583036680185 - 0.8091792062601594 + -0.1865038768386907 + -0.3042581052805431 + 0.2805750503956415 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](0)): [:, :, 1, 1] = - -0.08884153816767142 - 0.01266848788453655 + 0.2231243030608288 + 0.08092781366451458 [:, :, 2, 1] = - -0.08233565670221543 - -0.19529570387099443 + -0.19532663068884915 + 0.06701601057532594 [:, :, 3, 1] = - 0.26615655163874286 - -0.030807963939752325 + -0.19663933660092495 + 0.18928542492095224 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](1)): [:, :, 1, 1] = - -0.08884153816767142 - -0.08233565670221543 - 0.26615655163874286 + 0.2231243030608288 + -0.19532663068884915 + -0.19663933660092495 [:, :, 2, 1] = - 0.01266848788453655 - -0.19529570387099443 - -0.030807963939752325 + 0.08092781366451458 + 0.06701601057532594 + 0.18928542492095224 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](1)): [:, :, 1, 1] = - 0.11295002263154601 - -0.12116528285886852 + 0.848943627555492 + 0.04042732760057483 [:, :, 2, 1] = - -0.12116528285886852 - 0.9427967265595688 + 0.04042732760057483 + 0.9488832837137285 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](1)): [:, :, 1, 1] = - 0.15342625493257903 - -0.2515292440391659 - -0.19542823944023668 + 0.3319112495524563 + -0.2513780620550727 + 0.11442176515063972 [:, :, 2, 1] = - -0.2515292440391659 - 0.8663904396734251 - -0.019149938550354594 + -0.2513780620550727 + 0.19062163059480083 + -0.07285515149805918 [:, :, 3, 1] = - -0.19542823944023668 - -0.019149938550354594 - 0.5028458812146837 + 0.11442176515063972 + -0.07285515149805918 + 0.8447717161095469 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](0), Irrep[ℤ₂](1)): [:, :, 1, 1] = - 0.1686003193161515 - 0.0011891925030535217 + -0.01953773428314477 + 0.38089523295692806 [:, :, 2, 1] = - 0.005756952723922429 - 0.22823501584518602 + 0.020482580115089983 + -0.29217577804061706 [:, :, 3, 1] = - -0.4257666473283162 - -0.1736540989027453 + 0.3249518947305437 + -0.08448974163716166 * Data for sector (Irrep[ℤ₂](0), Irrep[ℤ₂](1)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](0)): [:, :, 1, 1] = - 0.1686003193161515 - 0.005756952723922429 - -0.4257666473283162 + -0.01953773428314477 + 0.020482580115089983 + 0.3249518947305437 [:, :, 2, 1] = - 0.0011891925030535217 - 0.22823501584518602 - -0.1736540989027453 + 0.38089523295692806 + -0.29217577804061706 + -0.08448974163716166 * Data for sector (Irrep[ℤ₂](1), Irrep[ℤ₂](0)) ← (Irrep[ℤ₂](1), Irrep[ℤ₂](0)): [:, :, 1, 1] = - 0.3606289129446726 - 0.14435806848821425 + 0.13776106219464307 + -0.11130120798799328 [:, :, 2, 1] = - 0.14435806848821425 - 0.1167085112346401
    julia> P*P ≈ Ptrue

    We also support other abelian symmetries, e.g.

    julia> V = U₁Space(0=>2,1=>1,-1=>1)Rep[U₁](0=>2, 1=>1, -1=>1)
    julia> dim(V)4
    julia> A = TensorMap(randn, V*V, V)TensorMap((Rep[U₁](0=>2, 1=>1, -1=>1) ⊗ Rep[U₁](0=>2, 1=>1, -1=>1)) ← Rep[U₁](0=>2, 1=>1, -1=>1)): + -0.11130120798799328 + 0.4949343415485528
    julia> P*P ≈ Ptrue

    We also support other abelian symmetries, e.g.

    julia> V = U₁Space(0=>2,1=>1,-1=>1)Rep[U₁](0=>2, 1=>1, -1=>1)
    julia> dim(V)4
    julia> A = TensorMap(randn, V*V, V)TensorMap((Rep[U₁](0=>2, 1=>1, -1=>1) ⊗ Rep[U₁](0=>2, 1=>1, -1=>1)) ← Rep[U₁](0=>2, 1=>1, -1=>1)): * Data for sector (Irrep[U₁](0), Irrep[U₁](0)) ← (Irrep[U₁](0),): [:, :, 1] = - -0.7585672722039413 0.5712846849036438 - -0.4942595360125473 -2.028419160671543 + -1.3528130444356097 0.15529769310422425 + -0.06772453622595191 0.7900890478191704 [:, :, 2] = - -1.1920881196521527 0.6856921395738031 - -1.0088545676957357 0.20747947315042475 + 1.1587289905182885 0.8065557003143712 + -0.7723933096594338 0.5192940383379407 * Data for sector (Irrep[U₁](-1), Irrep[U₁](1)) ← (Irrep[U₁](0),): [:, :, 1] = - -0.447775373494552 + 2.1110221033842995 [:, :, 2] = - -0.6437119627816857 + -0.7117484425475684 * Data for sector (Irrep[U₁](1), Irrep[U₁](-1)) ← (Irrep[U₁](0),): [:, :, 1] = - -0.03927824225874038 + 1.8102237819124818 [:, :, 2] = - -0.8261431213194221 + 2.008844718981481 * Data for sector (Irrep[U₁](1), Irrep[U₁](0)) ← (Irrep[U₁](1),): [:, :, 1] = - -1.0085204380746964 -0.9838760702297763 + 1.4775032763497797 -0.592131651728548 * Data for sector (Irrep[U₁](0), Irrep[U₁](1)) ← (Irrep[U₁](1),): [:, :, 1] = - -0.9336129759907349 - 1.2251378675501845 + 0.5119619031090205 + -0.9695105587875816 * Data for sector (Irrep[U₁](-1), Irrep[U₁](0)) ← (Irrep[U₁](-1),): [:, :, 1] = - -1.7497958705184484 -0.15288305694173226 + 0.5706168272963501 0.5106639495481592 * Data for sector (Irrep[U₁](0), Irrep[U₁](-1)) ← (Irrep[U₁](-1),): [:, :, 1] = - -0.34995220903281776 - -0.3217735380312506
    julia> dim(A)20
    julia> convert(Array, A)4×4×4 Array{Float64, 3}: + 0.03085576873234928 + 0.44390660518142316
    julia> dim(A)20
    julia> convert(Array, A)4×4×4 Array{Float64, 3}: [:, :, 1] = - -0.758567 0.571285 0.0 0.0 - -0.49426 -2.02842 0.0 0.0 - 0.0 0.0 0.0 -0.0392782 - 0.0 0.0 -0.447775 0.0 + -1.35281 0.155298 0.0 0.0 + -0.0677245 0.790089 0.0 0.0 + 0.0 0.0 0.0 1.81022 + 0.0 0.0 2.11102 0.0 [:, :, 2] = - -1.19209 0.685692 0.0 0.0 - -1.00885 0.207479 0.0 0.0 - 0.0 0.0 0.0 -0.826143 - 0.0 0.0 -0.643712 0.0 + 1.15873 0.806556 0.0 0.0 + -0.772393 0.519294 0.0 0.0 + 0.0 0.0 0.0 2.00884 + 0.0 0.0 -0.711748 0.0 [:, :, 3] = - 0.0 0.0 -0.933613 0.0 - 0.0 0.0 1.22514 0.0 - -1.00852 -0.983876 0.0 0.0 - 0.0 0.0 0.0 0.0 + 0.0 0.0 0.511962 0.0 + 0.0 0.0 -0.969511 0.0 + 1.4775 -0.592132 0.0 0.0 + 0.0 0.0 0.0 0.0 [:, :, 4] = - 0.0 0.0 0.0 -0.349952 - 0.0 0.0 0.0 -0.321774 - 0.0 0.0 0.0 0.0 - -1.7498 -0.152883 0.0 0.0
    julia> V = Rep[U₁×ℤ₂]((0, 0) => 2, (1, 1) => 1, (-1, 0) => 1)Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1)
    julia> dim(V)4
    julia> A = TensorMap(randn, V*V, V)TensorMap((Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1) ⊗ Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1)) ← Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1)): + 0.0 0.0 0.0 0.0308558 + 0.0 0.0 0.0 0.443907 + 0.0 0.0 0.0 0.0 + 0.570617 0.510664 0.0 0.0
    julia> V = Rep[U₁×ℤ₂]((0, 0) => 2, (1, 1) => 1, (-1, 0) => 1)Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1)
    julia> dim(V)4
    julia> A = TensorMap(randn, V*V, V)TensorMap((Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1) ⊗ Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1)) ← Rep[U₁ × ℤ₂]((0, 0)=>2, (-1, 0)=>1, (1, 1)=>1)): * Data for sector ((Irrep[U₁](0) ⊠ Irrep[ℤ₂](0)), (Irrep[U₁](0) ⊠ Irrep[ℤ₂](0))) ← ((Irrep[U₁](0) ⊠ Irrep[ℤ₂](0)),): [:, :, 1] = - -0.7951467784062274 -1.1720589319186527 - -1.0702342221186074 0.6809358422127522 + 0.5284522718991276 0.31967136838267335 + -1.4993533240808674 -0.6805605911863815 [:, :, 2] = - 0.5961642197996598 0.446586215002712 - 1.0550995396855745 -1.1225213765053739 + 0.22763873659405318 0.025758026857284105 + -2.539467189491498 0.2535254833350381 * Data for sector ((Irrep[U₁](-1) ⊠ Irrep[ℤ₂](0)), (Irrep[U₁](0) ⊠ Irrep[ℤ₂](0))) ← ((Irrep[U₁](-1) ⊠ Irrep[ℤ₂](0)),): [:, :, 1] = - -1.2715376041768276 -0.5613404737092911 + -0.3197575035296644 0.39321064866880096 * Data for sector ((Irrep[U₁](0) ⊠ Irrep[ℤ₂](0)), (Irrep[U₁](-1) ⊠ Irrep[ℤ₂](0))) ← ((Irrep[U₁](-1) ⊠ Irrep[ℤ₂](0)),): [:, :, 1] = - 0.9097509979594258 - -1.7032170126609065 + -1.3823556383220474 + 0.02783144207584994 * Data for sector ((Irrep[U₁](1) ⊠ Irrep[ℤ₂](1)), (Irrep[U₁](0) ⊠ Irrep[ℤ₂](0))) ← ((Irrep[U₁](1) ⊠ Irrep[ℤ₂](1)),): [:, :, 1] = - -0.5947878617177207 -0.15572972889588735 + 0.7551415402211361 -2.1839994519657333 * Data for sector ((Irrep[U₁](0) ⊠ Irrep[ℤ₂](0)), (Irrep[U₁](1) ⊠ Irrep[ℤ₂](1))) ← ((Irrep[U₁](1) ⊠ Irrep[ℤ₂](1)),): [:, :, 1] = - -0.8243434968029992 - 0.5800954183009349
    julia> dim(A)16
    julia> convert(Array, A)4×4×4 Array{Float64, 3}: + -0.08088211354520759 + -0.7484897764134931
    julia> dim(A)16
    julia> convert(Array, A)4×4×4 Array{Float64, 3}: [:, :, 1] = - -0.795147 -1.17206 0.0 0.0 - -1.07023 0.680936 0.0 0.0 + 0.528452 0.319671 0.0 0.0 + -1.49935 -0.680561 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 [:, :, 2] = - 0.596164 0.446586 0.0 0.0 - 1.0551 -1.12252 0.0 0.0 - 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 + 0.227639 0.025758 0.0 0.0 + -2.53947 0.253525 0.0 0.0 + 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 [:, :, 3] = - 0.0 0.0 0.909751 0.0 - 0.0 0.0 -1.70322 0.0 - -1.27154 -0.56134 0.0 0.0 - 0.0 0.0 0.0 0.0 + 0.0 0.0 -1.38236 0.0 + 0.0 0.0 0.0278314 0.0 + -0.319758 0.393211 0.0 0.0 + 0.0 0.0 0.0 0.0 [:, :, 4] = - 0.0 0.0 0.0 -0.824343 - 0.0 0.0 0.0 0.580095 - 0.0 0.0 0.0 0.0 - -0.594788 -0.15573 0.0 0.0

    Here, the dim of a TensorMap returns the number of linearly independent components, i.e. the number of non-zero entries in the case of an abelian symmetry. Also note that we can use × (obtained as \times+TAB) to combine different symmetry groups. The general space associated with symmetries is a GradedSpace, which is parametrized to the type of symmetry. For a group G, the fully specified type can be obtained as Rep[G], while for more general sectortypes I it can be constructed as Vect[I]. Furthermore, ℤ₂Space (also Z2Space as non-Unicode alternative) and U₁Space (or U1Space) are just convenient synonyms, e.g.

    julia> Rep[U₁](0=>3,1=>2,-1=>1) == U1Space(-1=>1,1=>2,0=>3)true
    julia> V = U₁Space(1=>2,0=>3,-1=>1)Rep[U₁](0=>3, 1=>2, -1=>1)
    julia> for s in sectors(V) + 0.0 0.0 0.0 -0.0808821 + 0.0 0.0 0.0 -0.74849 + 0.0 0.0 0.0 0.0 + 0.755142 -2.184 0.0 0.0

    Here, the dim of a TensorMap returns the number of linearly independent components, i.e. the number of non-zero entries in the case of an abelian symmetry. Also note that we can use × (obtained as \times+TAB) to combine different symmetry groups. The general space associated with symmetries is a GradedSpace, which is parametrized to the type of symmetry. For a group G, the fully specified type can be obtained as Rep[G], while for more general sectortypes I it can be constructed as Vect[I]. Furthermore, ℤ₂Space (also Z2Space as non-Unicode alternative) and U₁Space (or U1Space) are just convenient synonyms, e.g.

    julia> Rep[U₁](0=>3,1=>2,-1=>1) == U1Space(-1=>1,1=>2,0=>3)true
    julia> V = U₁Space(1=>2,0=>3,-1=>1)Rep[U₁](0=>3, 1=>2, -1=>1)
    julia> for s in sectors(V) @show s, dim(V, s) end(s, dim(V, s)) = (Irrep[U₁](0), 3) (s, dim(V, s)) = (Irrep[U₁](1), 2) (s, dim(V, s)) = (Irrep[U₁](-1), 1)
    julia> U₁Space(-1=>1,0=>3,1=>2) == GradedSpace(Irrep[U₁](1)=>2, Irrep[U₁](0)=>3, Irrep[U₁](-1)=>1)true
    julia> supertype(GradedSpace)ElementarySpace

    Note that GradedSpace is not immediately parameterized by some group G, but actually by the set of irreducible representations of G, denoted as Irrep[G]. Indeed, GradedSpace also supports a grading that is derived from the fusion ring of a (unitary) pre-fusion category. Also note that the order in which the charges and their corresponding subspace dimensionality are specified is irrelevant, and that the charges, henceforth called sectors (which is a more general name for charges or quantum numbers) are of a specific type, in this case Irrep[U₁] == U1Irrep. However, the Vect[I] constructor automatically converts the keys in the list of Pairs it receives to the correct type. Alternatively, we can directly create the sectors of the correct type and use the generic GradedSpace constructor. We can probe the subspace dimension of a certain sector s in a space V with dim(V, s). Finally, note that GradedSpace is also a subtype of EuclideanSpace, which implies that it still has the standard Euclidean inner product and we assume all representations to be unitary.

    TensorKit.jl also allows for non-abelian symmetries such as SU₂. In this case, the vector space is characterized via the spin quantum number (i.e. the irrep label of SU₂) for each of its subspaces, and is created using SU₂Space (or SU2Space or Rep[SU₂] or Vect[Irrep[SU₂]])

    julia> V = SU₂Space(0=>2,1/2=>1,1=>1)Rep[SU₂](0=>2, 1/2=>1, 1=>1)
    julia> dim(V)7
    julia> V == Vect[Irrep[SU₂]](0=>2, 1=>1, 1//2=>1)true

    Note that now V has a two-dimensional subspace with spin zero, and two one-dimensional subspaces with spin 1/2 and spin 1. However, a subspace with spin j has an additional 2j+1 dimensional degeneracy on which the irreducible representation acts. This brings the total dimension to 2*1 + 1*2 + 1*3. Creating a tensor with SU₂ symmetry yields

    julia> A = TensorMap(randn, V*V, V)TensorMap((Rep[SU₂](0=>2, 1/2=>1, 1=>1) ⊗ Rep[SU₂](0=>2, 1/2=>1, 1=>1)) ← Rep[SU₂](0=>2, 1/2=>1, 1=>1)):
     * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 0), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()):
     [:, :, 1] =
    - -1.0190203855160482   0.8689894172820456
    -  0.647821518012085   -1.0664822130909102
    + 1.2827713745042222    1.3482632754352881
    + 0.29078800376263014  -0.8772724205878165
     
     [:, :, 2] =
    - -0.35665916221476984  0.9788446409961856
    - -0.5849421671445161   0.5776426208227509
    + -0.28224529011272537  -0.6323069832927588
    + -0.5184969416970142    0.24152270913942422
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()):
     [:, :, 1] =
    - 2.129652167657322
    + -0.7756896672878734
     
     [:, :, 2] =
    - -1.2881848712877613
    + -0.7231796936642406
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2, 1/2), 0, (false, false), ()) ← FusionTree{Irrep[SU₂]}((0,), 0, (false,), ()):
     [:, :, 1] =
    - -0.48192615054734417
    + 0.3068890466866017
     
     [:, :, 2] =
    - -2.605746998527209
    + 0.38067832615913516
     * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 1/2), 1/2, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()):
     [:, :, 1] =
    - -0.5414141582494647
    - -0.2423223981880417
    + 0.8746907789956934
    + 0.6936826796477802
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2, 1), 1/2, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()):
     [:, :, 1] =
    - 0.34339569768468015
    + 1.2345252013253467
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2, 0), 1/2, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()):
     [:, :, 1] =
    - -0.7500647083190957  -1.2170733933307738
    + 0.5500154857552475  0.14663654489849973
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1/2), 1/2, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1/2,), 1/2, (false,), ()):
     [:, :, 1] =
    - -1.1810759114509803
    + 1.1297163205160774
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()):
     [:, :, 1] =
    - -0.7329269112361972
    + 0.0015545014872438046
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1, 0), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()):
     [:, :, 1] =
    - 1.3484022964842555  0.17609032126594468
    + 0.5396794993003502  -0.04768249425824412
     * Data for fusiontree FusionTree{Irrep[SU₂]}((1/2, 1/2), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()):
     [:, :, 1] =
    - -0.8937912880750394
    + -0.1725049683123535
     * Data for fusiontree FusionTree{Irrep[SU₂]}((0, 1), 1, (false, false), ()) ← FusionTree{Irrep[SU₂]}((1,), 1, (false,), ()):
     [:, :, 1] =
    -  0.33388650613011994
    - -0.9418382510596773
    julia> dim(A)24
    julia> convert(Array, A)7×7×7 Array{Float64, 3}: + -0.17180183250623146 + 1.3091307088547741
    julia> dim(A)24
    julia> convert(Array, A)7×7×7 Array{Float64, 3}: [:, :, 1] = - -1.01902 0.868989 0.0 0.0 0.0 0.0 0.0 - 0.647822 -1.06648 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 -0.340773 0.0 0.0 0.0 - 0.0 0.0 0.340773 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 1.22956 - 0.0 0.0 0.0 0.0 0.0 -1.22956 0.0 - 0.0 0.0 0.0 0.0 1.22956 0.0 0.0 + 1.28277 1.34826 0.0 0.0 0.0 0.0 0.0 + 0.290788 -0.877272 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.217003 0.0 0.0 0.0 + 0.0 0.0 -0.217003 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 -0.447845 + 0.0 0.0 0.0 0.0 0.0 0.447845 0.0 + 0.0 0.0 0.0 0.0 -0.447845 0.0 0.0 [:, :, 2] = - -0.356659 0.978845 0.0 0.0 0.0 0.0 0.0 - -0.584942 0.577643 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 -1.84254 0.0 0.0 0.0 - 0.0 0.0 1.84254 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 -0.743734 - 0.0 0.0 0.0 0.0 0.0 0.743734 0.0 - 0.0 0.0 0.0 0.0 -0.743734 0.0 0.0 + -0.282245 -0.632307 0.0 0.0 0.0 0.0 0.0 + -0.518497 0.241523 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.26918 0.0 0.0 0.0 + 0.0 0.0 -0.26918 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 -0.417528 + 0.0 0.0 0.0 0.0 0.0 0.417528 0.0 + 0.0 0.0 0.0 0.0 -0.417528 0.0 0.0 [:, :, 3] = - 0.0 0.0 -0.541414 0.0 0.0 0.0 0.0 - 0.0 0.0 -0.242322 0.0 0.0 0.0 0.0 - -0.750065 -1.21707 0.0 0.0 0.0 0.19826 0.0 - 0.0 0.0 0.0 0.0 -0.280381 0.0 0.0 - 0.0 0.0 0.0 -0.964344 0.0 0.0 0.0 - 0.0 0.0 0.681894 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.874691 0.0 0.0 0.0 0.0 + 0.0 0.0 0.693683 0.0 0.0 0.0 0.0 + 0.550015 0.146637 0.0 0.0 0.0 0.712753 0.0 + 0.0 0.0 0.0 0.0 -1.00799 0.0 0.0 + 0.0 0.0 0.0 0.92241 0.0 0.0 0.0 + 0.0 0.0 -0.652242 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 [:, :, 4] = - 0.0 0.0 0.0 -0.541414 0.0 0.0 0.0 - 0.0 0.0 0.0 -0.242322 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.280381 - -0.750065 -1.21707 0.0 0.0 0.0 -0.19826 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 -0.681894 0.0 0.0 0.0 - 0.0 0.0 0.964344 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.874691 0.0 0.0 0.0 + 0.0 0.0 0.0 0.693683 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 1.00799 + 0.550015 0.146637 0.0 0.0 0.0 -0.712753 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.652242 0.0 0.0 0.0 + 0.0 0.0 -0.92241 0.0 0.0 0.0 0.0 [:, :, 5] = - 0.0 0.0 0.0 0.0 0.333887 0.0 0.0 - 0.0 0.0 0.0 0.0 -0.941838 0.0 0.0 - 0.0 0.0 -0.893791 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 1.3484 0.17609 0.0 0.0 0.0 -0.518258 0.0 - 0.0 0.0 0.0 0.0 0.518258 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -0.171802 0.0 0.0 + 0.0 0.0 0.0 0.0 1.30913 0.0 0.0 + 0.0 0.0 -0.172505 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.539679 -0.0476825 0.0 0.0 0.0 0.0010992 0.0 + 0.0 0.0 0.0 0.0 -0.0010992 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 [:, :, 6] = - 0.0 0.0 0.0 0.0 0.0 0.333887 0.0 - 0.0 0.0 0.0 0.0 0.0 -0.941838 0.0 - 0.0 0.0 0.0 -0.632006 0.0 0.0 0.0 - 0.0 0.0 -0.632006 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 -0.518258 - 1.3484 0.17609 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.518258 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 -0.171802 0.0 + 0.0 0.0 0.0 0.0 0.0 1.30913 0.0 + 0.0 0.0 0.0 -0.121979 0.0 0.0 0.0 + 0.0 0.0 -0.121979 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0010992 + 0.539679 -0.0476825 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 -0.0010992 0.0 0.0 [:, :, 7] = - 0.0 0.0 0.0 0.0 0.0 0.0 0.333887 - 0.0 0.0 0.0 0.0 0.0 0.0 -0.941838 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 -0.893791 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - 0.0 0.0 0.0 0.0 0.0 0.0 -0.518258 - 1.3484 0.17609 0.0 0.0 0.0 0.518258 0.0
    julia> norm(A) ≈ norm(convert(Array, A))true

    In this case, the full Array representation of the tensor has again many zeros, but it is less obvious to recognize the dense blocks, as there are additional zeros and the numbers in the original tensor data do not match with those in the Array. The reason is of course that the original tensor data now needs to be transformed with a construction known as fusion trees, which are made up out of the Clebsch-Gordan coefficients of the group. Indeed, note that the non-zero blocks are also no longer labeled by a list of sectors, but by pair of fusion trees. This will be explained further in the manual. However, the Clebsch-Gordan coefficients of the group are only needed to actually convert a tensor to an Array. For working with tensors with SU₂Space indices, e.g. contracting or factorizing them, the Clebsch-Gordan coefficients are never needed explicitly. Instead, recoupling relations are used to symbolically manipulate the basis of fusion trees, and this only requires what is known as the topological data of the group (or its representation theory).

    In fact, this formalism extends beyond the case of group representations on vector spaces, and can also deal with super vector spaces (to describe fermions) and more general (unitary) fusion categories. Preliminary support for these generalizations is present in TensorKit.jl and will be extended in the near future.

    All of these concepts will be explained throughout the remainder of this manual, including several details regarding their implementation. However, to just use tensors and their manipulations (contractions, factorizations, ...) in higher level algorithms (e.g. tensoer network algorithms), one does not need to know or understand most of these details, and one can immediately refer to the general interface of the TensorMap type, discussed on the last page. Adhering to this interface should yield code and algorithms that are oblivious to the underlying symmetries and can thus work with arbitrary symmetric tensors.

    + 0.0 0.0 0.0 0.0 0.0 0.0 -0.171802 + 0.0 0.0 0.0 0.0 0.0 0.0 1.30913 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 -0.172505 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0010992 + 0.539679 -0.0476825 0.0 0.0 0.0 -0.0010992 0.0
    julia> norm(A) ≈ norm(convert(Array, A))true

    In this case, the full Array representation of the tensor has again many zeros, but it is less obvious to recognize the dense blocks, as there are additional zeros and the numbers in the original tensor data do not match with those in the Array. The reason is of course that the original tensor data now needs to be transformed with a construction known as fusion trees, which are made up out of the Clebsch-Gordan coefficients of the group. Indeed, note that the non-zero blocks are also no longer labeled by a list of sectors, but by pair of fusion trees. This will be explained further in the manual. However, the Clebsch-Gordan coefficients of the group are only needed to actually convert a tensor to an Array. For working with tensors with SU₂Space indices, e.g. contracting or factorizing them, the Clebsch-Gordan coefficients are never needed explicitly. Instead, recoupling relations are used to symbolically manipulate the basis of fusion trees, and this only requires what is known as the topological data of the group (or its representation theory).

    In fact, this formalism extends beyond the case of group representations on vector spaces, and can also deal with super vector spaces (to describe fermions) and more general (unitary) fusion categories. Preliminary support for these generalizations is present in TensorKit.jl and will be extended in the near future.

    All of these concepts will be explained throughout the remainder of this manual, including several details regarding their implementation. However, to just use tensors and their manipulations (contractions, factorizations, ...) in higher level algorithms (e.g. tensoer network algorithms), one does not need to know or understand most of these details, and one can immediately refer to the general interface of the TensorMap type, discussed on the last page. Adhering to this interface should yield code and algorithms that are oblivious to the underlying symmetries and can thus work with arbitrary symmetric tensors.

    diff --git a/dev/search/index.html b/dev/search/index.html index fff1f698..418414db 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · TensorKit.jl

    Loading search...

      +Search · TensorKit.jl

      Loading search...