diff --git a/src/states/finitemps.jl b/src/states/finitemps.jl index 9d0fe986a..279de9b24 100644 --- a/src/states/finitemps.jl +++ b/src/states/finitemps.jl @@ -311,6 +311,8 @@ function Base.similar(ψ::FiniteMPS{A, B}) where {A, B} return FiniteMPS{A, B}(similar(ψ.ALs), similar(ψ.ARs), similar(ψ.ACs), similar(ψ.Cs)) end +Base.isfinite(ψ::FiniteMPS) = true + Base.eachindex(ψ::FiniteMPS) = eachindex(ψ.AL) Base.eachindex(l::IndexStyle, ψ::FiniteMPS) = eachindex(l, ψ.AL) Base.checkbounds(::Type{Bool}, ψ::FiniteMPS, i::Integer) = 1 <= i <= length(ψ) diff --git a/src/states/infinitemps.jl b/src/states/infinitemps.jl index c9a4cf906..27c02dd2a 100644 --- a/src/states/infinitemps.jl +++ b/src/states/infinitemps.jl @@ -241,6 +241,7 @@ Base.size(ψ::InfiniteMPS, args...) = size(ψ.AL, args...) Base.length(ψ::InfiniteMPS) = length(ψ.AL) Base.eltype(ψ::InfiniteMPS) = eltype(typeof(ψ)) Base.eltype(::Type{<:InfiniteMPS{A}}) where {A} = A +Base.isfinite(ψ::InfiniteMPS) = false Base.copy(ψ::InfiniteMPS) = InfiniteMPS(copy(ψ.AL), copy(ψ.AR), copy(ψ.C), copy(ψ.AC)) function Base.copy!(ψ::InfiniteMPS, ϕ::InfiniteMPS) diff --git a/src/states/multilinemps.jl b/src/states/multilinemps.jl index 6f1199095..73f68fac6 100644 --- a/src/states/multilinemps.jl +++ b/src/states/multilinemps.jl @@ -13,7 +13,7 @@ Type that represents multiple lines of `InfiniteMPS` objects. virtualspaces::Matrix{<:Union{S, CompositeSpace{S}}) where {S<:ElementarySpace} MultilineMPS(As::AbstractMatrix{<:GenericMPSTensor}; kwargs...) - MultilineMPS(ALs::AbstractMatrix{<:GenericMPSTensor}, + MultilineMPS(ALs::AbstractMatrix{<:GenericMPSTensor}, C₀::AbstractVector{<:MPSBondTensor}; kwargs...) See also: [`Multiline`](@ref) @@ -101,6 +101,8 @@ Base.convert(::Type{InfiniteMPS}, st::MultilineMPS) = only(st) Base.eltype(t::MultilineMPS) = eltype(t[1]) Base.copy!(ψ::MultilineMPS, ϕ::MultilineMPS) = (copy!.(parent(ψ), parent(ϕ)); ψ) +Base.isfinite(ψ::MultilineMPS) = false + for f_space in (:physicalspace, :left_virtualspace, :right_virtualspace) @eval $f_space(t::MultilineMPS, i::Int, j::Int) = $f_space(t[i], j) @eval $f_space(t::MultilineMPS, I::CartesianIndex{2}) = $f_space(t, Tuple(I)...) diff --git a/test/states.jl b/test/states.jl index 04990ea50..7762b844c 100644 --- a/test/states.jl +++ b/test/states.jl @@ -24,6 +24,7 @@ module TestStates L = rand(3:20) ψ = FiniteMPS(rand, elt, L, d, D) + @test isfinite(ψ) @test @constinferred physicalspace(ψ) == fill(d, L) @test all(x -> x ≾ D, @constinferred left_virtualspace(ψ)) @test all(x -> x ≾ D, @constinferred right_virtualspace(ψ)) @@ -99,6 +100,7 @@ module TestStates ψ = InfiniteMPS([rand(elt, D * d, D), rand(elt, D * d, D)]; tol) + @test !isfinite(ψ) @test physicalspace(ψ) == fill(d, 2) @test all(x -> x ≾ D, left_virtualspace(ψ)) @test all(x -> x ≾ D, right_virtualspace(ψ))