Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/states/finitemps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(ψ)
Expand Down
1 change: 1 addition & 0 deletions src/states/infinitemps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/states/multilinemps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)...)
Expand Down
2 changes: 2 additions & 0 deletions test/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(ψ))
Expand Down Expand Up @@ -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(ψ))
Expand Down