From 889c5189562b316b46e8b36c6f105a56018721ee Mon Sep 17 00:00:00 2001 From: Lander Burgelman <39218680+leburgel@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:11:09 +0100 Subject: [PATCH] Some docs fixes (#103) * Some docs fixes * Fix `TrivialTensor` docstring * Simplify subtype restrictions in alias definitions * Format * Small fix in deligne product docs --- docs/src/lib/sectors.md | 5 +++-- docs/src/lib/spaces.md | 5 +++-- docs/src/lib/tensors.md | 13 ++++++------- src/sectors/product.jl | 2 +- src/tensors/abstracttensor.jl | 4 ++-- src/tensors/tensor.jl | 34 +++++++++++++++++++++++++++++++--- 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/docs/src/lib/sectors.md b/docs/src/lib/sectors.md index 80cfdf02..4f45b387 100644 --- a/docs/src/lib/sectors.md +++ b/docs/src/lib/sectors.md @@ -37,7 +37,7 @@ Rsymbol Bsymbol dim(::Sector) frobeniusschur -twist +twist(::Sector) Base.isreal(::Type{<:Sector}) TensorKit.vertex_labeltype TensorKit.vertex_ind2label @@ -69,7 +69,8 @@ foldleft cycleclockwise cycleanticlockwise repartition -transpose +transpose(f₁::FusionTree{I}, f₂::FusionTree{I}, + p1::IndexTuple{N₁}, p2::IndexTuple{N₂}) where {I<:Sector,N₁,N₂} braid(f₁::FusionTree{I}, f₂::FusionTree{I}, levels1::IndexTuple, levels2::IndexTuple, p1::IndexTuple{N₁}, p2::IndexTuple{N₂}) where {I<:Sector,N₁,N₂} permute(f₁::FusionTree{I}, f₂::FusionTree{I}, p1::IndexTuple{N₁}, p2::IndexTuple{N₂}) where {I<:Sector,N₁,N₂} ``` diff --git a/docs/src/lib/spaces.md b/docs/src/lib/spaces.md index 8c2aab18..87781715 100644 --- a/docs/src/lib/spaces.md +++ b/docs/src/lib/spaces.md @@ -40,7 +40,8 @@ sectors hassector dim dims -blocksectors +blocksectors(::ProductSpace) +blocksectors(::HomSpace) blockdim space ``` @@ -61,7 +62,7 @@ while the following also work on both `ElementarySpace` and `ProductSpace` ```@docs fuse :⊗ -:⊠ +⊠(::VectorSpace, ::VectorSpace) one ismonomorphic isepimorphic diff --git a/docs/src/lib/tensors.md b/docs/src/lib/tensors.md index 219cfa8a..c460ebb9 100644 --- a/docs/src/lib/tensors.md +++ b/docs/src/lib/tensors.md @@ -10,7 +10,6 @@ The type hierarchy of tensors is as follows: ```@docs AbstractTensorMap -AbstractTensor TensorMap AdjointTensorMap BraidingTensor @@ -48,7 +47,7 @@ The following methods exist to obtain type information: ```@docs spacetype -sectortype +sectortype(::Type{<:AbstractTensorMap{S}}) where {S<:IndexSpace} storagetype tensormaptype ``` @@ -57,7 +56,7 @@ To obtain information about the indices, you can use: ```@docs domain codomain -space +space(::AbstractTensorMap) numin numout numind @@ -68,8 +67,8 @@ allind To obtain information about the data, the following methods exist: ```@docs -blocksectors -blockdim +blocksectors(::AbstractTensorMap) +blockdim(::AbstractTensorMap, ::Sector) block blocks fusiontrees @@ -92,8 +91,8 @@ scaling, as well as the selection of a custom backend. ```@docs permute(t::AbstractTensorMap{S}, (p₁, p₂)::Index2Tuple{N₁,N₂}; copy::Bool=false) where {S,N₁,N₂} braid(t::AbstractTensorMap{S}, (p₁, p₂)::Index2Tuple, levels::IndexTuple; copy::Bool=false) where {S} -transpose -twist +transpose(::AbstractTensorMap, ::Index2Tuple) +twist(::AbstractTensorMap, ::Int) ``` ```@docs permute!(tdst::AbstractTensorMap{S,N₁,N₂}, tsrc::AbstractTensorMap{S}, p::Index2Tuple{N₁,N₂}) where {S,N₁,N₂} diff --git a/src/sectors/product.jl b/src/sectors/product.jl index c99bd762..3bc45526 100644 --- a/src/sectors/product.jl +++ b/src/sectors/product.jl @@ -180,7 +180,7 @@ const deligneproduct = ⊠ 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 `\boxtimes+TAB`) labels the +fusion category ``C₁`` and ``C₂``, `s1 ⊠ s2` (obtained as `\\boxtimes+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 diff --git a/src/tensors/abstracttensor.jl b/src/tensors/abstracttensor.jl index 71247830..604608ae 100644 --- a/src/tensors/abstracttensor.jl +++ b/src/tensors/abstracttensor.jl @@ -211,13 +211,13 @@ hasblock blocksectors(t::AbstractTensorMap) Return an iterator over all coupled sectors of a tensor. -""" blocksectors +""" blocksectors(::AbstractTensorMap) @doc """ blockdim(t::AbstractTensorMap, c::Sector) -> Base.Dims Return the dimensions of the block of a tensor corresponding to a coupled sector `c`. -""" blockdim +""" blockdim(::AbstractTensorMap, ::Sector) @doc """ fusiontrees(t::AbstractTensorMap) diff --git a/src/tensors/tensor.jl b/src/tensors/tensor.jl index 2415e419..2ec6a3b5 100644 --- a/src/tensors/tensor.jl +++ b/src/tensors/tensor.jl @@ -36,9 +36,32 @@ struct TensorMap{S<:IndexSpace, N₁, N₂, I<:Sector, A<:Union{<:DenseMatrix,Se end #! format: on -const Tensor{S<:IndexSpace,N,I<:Sector,A,F₁,F₂} = TensorMap{S,N,0,I,A,F₁,F₂} -const TrivialTensorMap{S<:IndexSpace,N₁,N₂,A<:DenseMatrix} = TensorMap{S,N₁,N₂,Trivial,A, - Nothing,Nothing} +""" + Tensor{S, N, I, A, F₁, F₂} = TensorMap{S, N, 0, I, A, F₁, F₂} + +Specific subtype of [`AbstractTensor`](@ref) for representing tensors whose data is stored +in blocks of some subtype of `DenseMatrix`. + +A `Tensor{S, N, I, A, F₁, F₂}` is actually a special case `TensorMap{S, N, 0, I, A, F₁, F₂}`, +i.e. a tensor map with only a non-trivial output space. +""" +const Tensor{S,N,I,A,F₁,F₂} = TensorMap{S,N,0,I,A,F₁,F₂} +""" + TrivialTensorMap{S<:IndexSpace, N₁, N₂, A<:DenseMatrix} = TensorMap{S, N₁, N₂, Trivial, + A, Nothing, Nothing} + +A special case of [`TensorMap`](@ref) for representing tensor maps with trivial symmetry, +i.e., whose `sectortype` is `Trivial`. +""" +const TrivialTensorMap{S,N₁,N₂,A<:DenseMatrix} = TensorMap{S,N₁,N₂,Trivial,A, + Nothing,Nothing} +""" + TrivialTensor{S, N, A} = TrivialTensorMap{S, N, 0, A} + +A special case of [`Tensor`](@ref) for representing tensors with trivial symmetry, i.e., +whose `sectortype` is `Trivial`. +""" +const TrivialTensor{S,N,A} = TrivialTensorMap{S,N,0,A} """ tensormaptype(::Type{S}, N₁::Int, N₂::Int, [::Type{T}]) where {S<:IndexSpace,T} -> ::Type{<:TensorMap} @@ -72,6 +95,11 @@ domain(t::TensorMap) = t.dom blocksectors(t::TrivialTensorMap) = OneOrNoneIterator(dim(t) != 0, Trivial()) blocksectors(t::TensorMap) = keys(t.data) +""" + storagetype(::Union{T,Type{T}}) where {T<:TensorMap} -> Type{A<:DenseMatrix} + +Return the type of the storage `A` of the tensor map. +""" function storagetype(::Type{<:TensorMap{<:IndexSpace,N₁,N₂,Trivial,A}}) where {N₁,N₂,A<:DenseMatrix} return A