diff --git a/src/environments/bp_environments.jl b/src/environments/bp_environments.jl index bc0429e0a..70460f721 100644 --- a/src/environments/bp_environments.jl +++ b/src/environments/bp_environments.jl @@ -27,6 +27,7 @@ struct BPEnv{T} "4 x rows x cols array of message tensors, where the first dimension specifies the spatial direction" messages::Array{T, 3} end +TensorKit.storagetype(::Type{BPEnv{T}}) where {T} = storagetype(T) """ Construct a message tensor on a certain bond of a network, diff --git a/src/environments/ctmrg_environments.jl b/src/environments/ctmrg_environments.jl index d6f39aa7d..a89f79d35 100644 --- a/src/environments/ctmrg_environments.jl +++ b/src/environments/ctmrg_environments.jl @@ -235,6 +235,11 @@ CTMRGEnv(env::CTMRGEnv) = CTMRGEnv(env.corners, env.edges) @non_differentiable CTMRGEnv(state::Union{InfinitePartitionFunction, InfinitePEPS}, args...) +function TensorKit.storagetype(::Type{CTMRGEnv{C, E}}) where {C, E} + T = promote_type(scalartype(C), scalartype(E)) + return TensorKit.promote_storagetype(T, C, E) +end + # Custom adjoint for CTMRGEnv constructor, needed for fixed-point differentiation function ChainRulesCore.rrule( ::Type{CTMRGEnv}, corners::Array{C, 3}, edges::Array{T, 3} diff --git a/src/environments/suweight.jl b/src/environments/suweight.jl index dbf7b0059..3ccd5ba38 100644 --- a/src/environments/suweight.jl +++ b/src/environments/suweight.jl @@ -139,6 +139,7 @@ TensorKit.spacetype(w::SUWeight) = spacetype(typeof(w)) TensorKit.spacetype(::Type{T}) where {E, T <: SUWeight{E}} = spacetype(E) TensorKit.sectortype(w::SUWeight) = sectortype(typeof(w)) TensorKit.sectortype(::Type{<:SUWeight{T}}) where {T} = sectortype(spacetype(T)) +TensorKit.storagetype(::Type{SUWeight{T}}) where {T} = storagetype(T) ## Bipartite check function _is_bipartite(wts::SUWeight) diff --git a/src/networks/infinitesquarenetwork.jl b/src/networks/infinitesquarenetwork.jl index fe62377b3..bc1c9b7d2 100644 --- a/src/networks/infinitesquarenetwork.jl +++ b/src/networks/infinitesquarenetwork.jl @@ -56,9 +56,7 @@ end ## Spaces TensorKit.spacetype(::Type{T}) where {T <: InfiniteSquareNetwork} = spacetype(eltype(T)) -function TensorKit.storagetype(::Type{T}) where {T <: InfiniteSquareNetwork} - return storagetype(eltype(T)) -end +TensorKit.storagetype(::Type{InfiniteSquareNetwork{O}}) where {O} = storagetype(O) virtualspace(n::InfiniteSquareNetwork, r::Int, c::Int, dir) = virtualspace(n[r, c], dir) ## Vector interface diff --git a/src/operators/localoperator.jl b/src/operators/localoperator.jl index c35e5ddb9..e3df138b1 100644 --- a/src/operators/localoperator.jl +++ b/src/operators/localoperator.jl @@ -87,6 +87,7 @@ function add_term!( return operator end +TensorKit.storagetype(lo::LocalOperator{T, S}) where {T, S} = TensorKit.promote_storagetype(values(lo.terms)...) """ checklattice(Bool, args...) diff --git a/src/operators/transfermatrix.jl b/src/operators/transfermatrix.jl index 76cfc54e3..85199a75f 100644 --- a/src/operators/transfermatrix.jl +++ b/src/operators/transfermatrix.jl @@ -115,6 +115,9 @@ function MultilineTransferPEPO(T::InfinitePEPS, O::InfinitePEPO, dir) return MPSKit.Multiline(map(cr -> InfiniteTransferPEPO(T, O, dir, cr), 1:rowsize)) end +TensorKit.storagetype(::Type{InfiniteTransferPEPS{T}}) where {T} = storagetype(T) +TensorKit.storagetype(::Type{InfiniteTransferPEPO{H, T, O}}) where {H, T, O} = TensorKit.promote_storagetype(T, O) + # # Common interface # diff --git a/test/testsuite/boundarymps/vumps.jl b/test/testsuite/boundarymps/vumps.jl index c2fe66f8f..bcd088f51 100644 --- a/test/testsuite/boundarymps/vumps.jl +++ b/test/testsuite/boundarymps/vumps.jl @@ -16,6 +16,7 @@ function boundary_mps_one_one_peps(AT) Vpeps = ComplexSpace(2) psi = adapt(AT, InfinitePEPS(Vpeps, Vpeps)) T = PEPSKit.InfiniteTransferPEPS(psi, 1, 1) + @test TensorKit.storagetype(T) <: AT foreach(V -> (@test V == Vpeps ⊗ Vpeps'), physicalspace(T)) mps = initialize_mps(T, [ComplexSpace(20)]) @@ -117,6 +118,7 @@ function boundary_mps_pepo_runthrough(AT) O = ising_pepo(1) psi = adapt(AT, PEPSKit.initializePEPS(O, Vpeps)) T = InfiniteTransferPEPO(psi, O, 1, 1) + @test TensorKit.storagetype(T) <: AT foreach(V -> (@test V == Vpeps ⊗ Vpepo ⊗ Vpeps'), physicalspace(T)) mps = initialize_mps(rand, scalartype(T), T, [ComplexSpace(10)]) diff --git a/test/types/localoperator.jl b/test/types/localoperator.jl index 412d9b9a2..576f2bb4c 100644 --- a/test/types/localoperator.jl +++ b/test/types/localoperator.jl @@ -17,6 +17,7 @@ if !is_buildkite terms = ((CartesianIndex(1, 1), CartesianIndex(1, 2)) => t,) op = LocalOperator(physical_spaces, terms...) + @test TensorKit.storagetype(op) == TensorKit.storagetype(t) @test op isa LocalOperator @test length(op.terms) == 1