From 08329c9f6218c5a86123f479dbfafbd83a63fefa Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Mon, 14 Oct 2024 15:30:22 -0400 Subject: [PATCH 1/5] Begin removal of downstream functions --- src/ITensorInfiniteMPS.jl | 2 - src/ITensorNetworks.jl | 332 -------------------------------------- src/ITensors.jl | 72 ++------- 3 files changed, 12 insertions(+), 394 deletions(-) delete mode 100644 src/ITensorNetworks.jl diff --git a/src/ITensorInfiniteMPS.jl b/src/ITensorInfiniteMPS.jl index 1a2a7e9d..40e9fda9 100644 --- a/src/ITensorInfiniteMPS.jl +++ b/src/ITensorInfiniteMPS.jl @@ -26,7 +26,6 @@ import Base: getindex, length, setindex!, +, -, * import ITensors: AbstractMPS, ⊕ include("ITensors.jl") -include("ITensorNetworks.jl") include("itensormap.jl") include("celledvectors.jl") include("abstractinfinitemps.jl") @@ -60,7 +59,6 @@ export Cell, InfiniteBlockMPO, InfiniteSumLocalOps, ITensorMap, - ITensorNetwork, TransferMatrix, @Model_str, Model, diff --git a/src/ITensorNetworks.jl b/src/ITensorNetworks.jl deleted file mode 100644 index b7747849..00000000 --- a/src/ITensorNetworks.jl +++ /dev/null @@ -1,332 +0,0 @@ - -export eachneighborindex, nnodes - -const IndexSetNetwork = Vector{Dict{Int,IndexSet}} - -IndexSetNetwork(n::Integer) = [eltype(IndexSetNetwork)() for _ in 1:n] - -struct ITensorNetwork - itensors::Vector{ITensor} - indsnetwork::IndexSetNetwork -end - -Base.length(tn::ITensorNetwork) = length(itensors(tn)) -Base.copy(tn::ITensorNetwork) = ITensorNetwork(copy(itensors(tn)), copy.(inds(tn))) - -# Call this with tn[1:end] -itensors(tn::ITensorNetwork) = tn.itensors - -ITensors.inds(tn::ITensorNetwork) = tn.indsnetwork - -# TODO: should this return an ITensorNetwork with 1 node? -Base.getindex(tn::ITensorNetwork, i::Integer) = itensors(tn)[i] - -# TODO: should this update reverse(ij)? -function Base.setindex!(isn::IndexSetNetwork, is::IndexSet, ij::Pair{<:Integer,<:Integer}) - i, j = ij - isn[i][j] = is - #isn[j][i] = dag(is) - return isn -end - -# TODO: also update indsnetwork with the new indices -Base.setindex!(tn::ITensorNetwork, t::ITensor, i::Integer) = (itensors(tn)[i] = t) - -function setinds!(tn::ITensorNetwork, is::IndexSet, ij::Pair{<:Integer,<:Integer}) - return inds(tn)[ij] = is -end - -# Iteration iterates through the ITensors of the network -Base.iterate(tn::ITensorNetwork, args...) = iterate(itensors(tn), args...) - -# Iterate over the nodes that are neighbors of the specified node -# For example, for an ITensorNetwork `tn = [A₁, A₂, A₃, A₄]`: -# -# --A₁--A₂--A₃--A₄-- -# -# `collect(eachneighborindex(tn, 2)) == [1, 3]` -eachneighborindex(isn::IndexSetNetwork, i::Integer) = Iterators.filter(==(i), keys(isn[i])) - -# Iterator over each IndexSet connected to the node `i` -eachlinkinds(isn::IndexSetNetwork, i::Integer) = values(isn[i]) - -eachneighborindex(tn::ITensorNetwork, i::Integer) = eachneighborindex(inds(tn)) - -function ITensorNetwork(tensors::Vector{<:ITensor}) - N = length(tensors) - indsnetwork = [eltype(IndexSetNetwork)() for n in 1:N] - # Get the "link" indices - # Determine the neighborhood of each node/tensor - # through common indices - for i in 1:N - for j in (i + 1):N - linkindsᵢⱼ = commoninds(tensors[i], tensors[j]) - if !isempty(linkindsᵢⱼ) - indsnetwork[i][j] = linkindsᵢⱼ - indsnetwork[j][i] = dag(indsnetwork[i][j]) - end - end - end - # Get the "site" indices - for i in 1:N - indsnetwork[i][i] = uniqueinds(tensors[i], eachlinkinds(indsnetwork, i)...) - end - return ITensorNetwork(tensors, indsnetwork) -end - -function Base.getindex(tn::IndexSetNetwork, ij::Pair{<:Integer,<:Integer}) - i, j = ij - @assert j ∈ 1:nnodes(tn) - return get(tn[i], j, IndexSet()) -end - -ITensors.inds(tn::ITensorNetwork, ij::Pair{<:Integer,<:Integer}) = inds(tn)[ij] - -function ITensors.linkinds(tn::ITensorNetwork, ij::Pair{<:Integer,<:Integer}) - i, j = ij - @assert i ≠ j - return inds(tn, ij) -end - -# Get the self edges/site indices of node `i` -ITensors.siteinds(tn::ITensorNetwork, i::Integer) = inds(tn, i => i) - -# Get all of the self edges/site indices of the network, returning `s` such -# that `s[i] == siteinds(tn, i)` -ITensors.siteinds(tn::ITensorNetwork) = IndexSet[siteinds(tn, i) for i in 1:nnodes(tn)] - -# Number of nodes/vertices/tensors of the graph/network -nnodes(isn::IndexSetNetwork) = length(isn) -function nnodes(tn::ITensorNetwork) - n = nnodes(inds(tn)) - @assert n == length(itensors(tn)) - return n -end - -⊗(Ts::ITensor...) = ITensorNetwork([Ts...]) - -# TODO: build this by appending T to the network instead -# of rebuilding the entire network -⊗(Ts::ITensorNetwork, T::ITensor) = ITensorNetwork([Ts..., T]) - -⊗(TN1::ITensorNetwork, TN2::ITensorNetwork) = ITensorNetwork([TN1..., TN2...]) - -# -# ITensors.jl extensions -# - -ITensors.unioninds(is::Vector{<:IndexSet}) = unioninds(is...) - -Base.:*(tn::ITensorNetwork) = *(tn...) -Base.:*(t::ITensor, tn::ITensorNetwork) = *(t, tn...) -Base.:*(tn::ITensorNetwork, t::ITensor) = *(tn..., t) -Base.:*(tn1::ITensorNetwork, tn2::ITensorNetwork) = *(tn1..., tn2...) - -function ITensors.dag(tn::ITensorNetwork) - tn = copy(tn) - N = nnodes(tn) - for i in 1:N - tn[i] = dag(tn[i]) - for j in keys(inds(tn)[i]) - setinds!(tn, dag(inds(tn, i => j)), i => j) - end - end - return tn -end - -# -# Contraction sequence optimization -# - -function trivial_contraction_sequence(tn::ITensorNetwork) - N = nnodes(tn) - # N-1 pairwise contractions - t = 1 - for n in 2:N - t = [n, t] - end - return t -end - -function contract_pair!(T⃗, ab) - a, b = ab - Tᵃ, Tᵇ = T⃗[a], T⃗[b] - # Contract a and b - Tᵈ = Any[Tᵃ, Tᵇ] - # Remove tensors Tᵃ and Tᵇ from the list of tensors - deleteat!(T⃗, [a, b]) - # Append Tᵈ to the list of tensors - push!(T⃗, Tᵈ) - return T⃗ -end - -# Get all tensor pairs for a given number of tensors -function tensor_pairs(n::Integer) - pairs = Pair{Int,Int}[] - for i in 1:(n - 1) - for j in (i + 1):n - push!(pairs, i => j) - end - end - return pairs -end - -# Depth-first constructive approach -# TODO: this isn't pruning repeats -function each_contraction_sequence(n::Integer) - Ts = Any[] - each_each_ab = Iterators.product( - (ITensorInfiniteMPS.tensor_pairs(n) for n in reverse(2:n))... - ) - for each_ab in each_each_ab - T = Any[1:n...] - for ab in each_ab - contract_pair!(T, ab) - end - push!(Ts, T[]) - end - return Ts -end - -each_contraction_sequence(tn::ITensorNetwork) = each_contraction_sequence(nnodes(tn)) -function each_contraction_sequence(isn::Vector{<:Vector{<:Index}}) - return each_contraction_sequence(length(isn)) -end -each_contraction_sequence(isn::IndexSetNetwork) = each_contraction_sequence(length(isn)) - -# -# Contraction cost using Vector{<: Vector{<: IndexSet}} -# - -contraction_cost(T1::ITensor, T2::ITensor) = contraction_cost(inds(T1), inds(T2)) - -# -# TODO: use the following for symdiff -# Index[setdiff(inds(TN[1]), inds(TN[2]))..., setdiff(inds(TN[2]), inds(TN[1]))...] -# - -function _intersect(A::Vector{IndexT}, B::Vector{IndexT}) where {IndexT<:Index} - R = IndexT[] - for a in A - a ∈ B && push!(R, a) - end - return R -end - -function _setdiff(A::Vector{IndexT}, B::Vector{IndexT}) where {IndexT<:Index} - R = IndexT[] - for a in A - a ∉ B && push!(R, a) - end - return R -end - -# Faster symdiff -function _symdiff(is1::Vector{IndexT}, is2::Vector{IndexT}) where {IndexT<:Index} - setdiff12 = _setdiff(is1, is2) - setdiff21 = _setdiff(is2, is1) - display(setdiff12) - display(setdiff21) - return IndexT[_setdiff(is1, is2)..., _setdiff(is2, is1)...] -end - -# Return the noncommon indices and the cost of contraction -function _contract_inds(is1::Vector{IndexT}, is2::Vector{IndexT}) where {IndexT<:Index} - N1 = length(is1) - N2 = length(is2) - Ncommon = 0 - dim_common = 1 - is1_contracted = fill(false, N1) - is2_contracted = fill(false, N2) - # Determine the contracted indices - for (n1, i1) in pairs(is1) - n2 = findfirst(==(i1), is2) - if !isnothing(n2) - Ncommon += 1 - dim_common *= dim(i1) - is1_contracted[n1] = true - is2_contracted[n2] = true - end - end - cost = _dim(is1) * _dim(is2) ÷ dim_common - Nnoncommon = N1 + N2 - 2 * Ncommon - isR = Vector{IndexT}(undef, Nnoncommon) - n = 1 - for n1 in 1:N1 - if !is1_contracted[n1] - isR[n] = is1[n1] - n += 1 - end - end - for n2 in 1:N2 - if !is2_contracted[n2] - isR[n] = is2[n2] - n += 1 - end - end - return isR, cost -end - -function _dim(is::Vector{<:Index}) - isempty(is) && return 1 - return mapreduce(dim, *, is) -end - -function contraction_cost(is1::Vector{IndexT}, is2::Vector{IndexT}) where {IndexT<:Index} - # 1.169417 s for N = 7 network - #common_is = _intersect(is1, is2) - #noncommon_is = _symdiff(is1, is2) - #return noncommon_is, _dim(common_is) * _dim(noncommon_is) - - # 0.635962 s for N = 7 network - return _contract_inds(is1, is2) -end - -function contraction_cost!( - cost::Ref{Int}, is1::Vector{IndexT}, is2::Vector{IndexT} -) where {IndexT<:Index} - contracted_is, current_cost = contraction_cost(is1, is2) - cost[] += current_cost - return contracted_is -end - -contraction_cost!(cost::Ref{Int}, ::Vector{Union{}}, ::Vector{Union{}}) = (cost[] += 1) - -function contraction_cost!(cost::Ref{Int}, is::Vector{<:Vector{<:Index}}, n::Integer) - return is[n] -end - -function contraction_cost!(cost::Ref{Int}, is::Vector{<:Vector{<:Index}}, sequence) - return contraction_cost!( - cost, contraction_cost!(cost, is, sequence[1]), contraction_cost!(cost, is, sequence[2]) - ) -end - -function contraction_cost(isn::Vector{<:Vector{<:Index}}, sequence) - # TODO: use the network itself - cost = Ref(0) - contraction_cost!(cost, isn, sequence) - return cost[] -end - -function contraction_cost(tn::ITensorNetwork, sequence) - return contraction_cost(collect.(inds.(tn)), sequence) -end - -# Return the optimal contraction sequence -function optimal_contraction_sequence(isn::Vector{<:Vector{<:Index}}) - sequences = each_contraction_sequence(isn) - contraction_costs = map(sequence -> contraction_cost(isn, sequence), sequences) - mincost, minsequenceindex = findmin(contraction_costs) - return sequences[minsequenceindex], mincost -end - -# Return the optimal contraction sequence -function optimal_contraction_sequence(tn::ITensorNetwork) - if length(tn) == 1 - return Any[1], 0 - end - #return optimal_contraction_sequence(inds(tn)) - #return optimal_contraction_sequence(inds.(itensors(tn))) - return optimal_contraction_sequence(collect.(inds.(itensors(tn)))) -end diff --git a/src/ITensors.jl b/src/ITensors.jl index 52fe6d7b..9e919a8a 100644 --- a/src/ITensors.jl +++ b/src/ITensors.jl @@ -1,14 +1,8 @@ using ITensorMPS: MPS using ITensors.NDTensors: NDTensors, tensor -using ITensors: ITensors, IndexSet, QN, Tag, TagSet, dag, inds, isdiag, sim +using ITensors: ITensors, QN, Tag, TagSet, dag, inds, isdiag, sim using LinearAlgebra: LinearAlgebra, eigen -############################################################################ -# imports.jl -# - -import Base: * - ############################################################################ # NDTensors # @@ -36,21 +30,14 @@ end # # Used for findfirst -Base.keys(ts::TagSet) = Base.OneTo(length(ts)) +Base.keys(ts::TagSet) = Base.OneTo(length(ts)) # added import ITensors: Tag, commontags -macro tag_str(s) - return Tag(s) -end - -commontags(ts::TagSet, i::Index) = commontags(ts, tags(i)) -commontags(t::Vector) = foldl(commontags, t) +maxlength(tag::Tag) = length(tag.data) # added -maxlength(tag::Tag) = length(tag.data) - -function Base.length(tag::Tag) +function Base.length(tag::Tag) # added n = 1 while n <= maxlength(tag) && tag[n] != zero(eltype(tag)) n += 1 @@ -58,17 +45,17 @@ function Base.length(tag::Tag) return n - 1 end -Base.lastindex(tag::Tag) = length(tag) +Base.lastindex(tag::Tag) = length(tag) # added -Base.getindex(tag::Tag, r::UnitRange) = Tag([tag[n] for n in r]) +Base.getindex(tag::Tag, r::UnitRange) = Tag([tag[n] for n in r]) #added # TODO: make this work directly on a Tag, without converting # to String -function Base.parse(::Type{T}, tag::Tag) where {T<:Integer} +function Base.parse(::Type{T}, tag::Tag) where {T<:Integer} #added return parse(T, string(tag)) end -function Base.startswith(tag::Tag, subtag::Tag) +function Base.startswith(tag::Tag, subtag::Tag) #added for n in 1:length(subtag) tag[n] ≠ subtag[n] && return false end @@ -120,36 +107,10 @@ function ⊕( end ⊕(qns::Vector{Pair{QN,Int}}, qn::Pair{QN,Int}) = push!(copy(qns), qn) -############################################################################ -# indexset.jl -# - -ITensors.IndexSet(is::IndexSet...) = unioninds(is) -ITensors.IndexSet(is::Tuple{Vararg{IndexSet}}) = unioninds(is...) - -Base.copy(is::IndexSet) = IndexSet(copy.(ITensors.data(is))) - -ITensors.noncommoninds(is::IndexSet) = is - ############################################################################ # itensor.jl # -# Helpful for making sure the ITensor doesn't contract -ITensors.sim(A::ITensor) = ITensors.setinds(A, sim(inds(A))) - -LinearAlgebra.isdiag(T::ITensor) = isdiag(tensor(T)) - -function eigendecomp(T::ITensor; ishermitian=true, kwargs...) - @assert ishermitian - D, U = eigen(T; ishermitian=ishermitian, kwargs...) - return U', D, dag(U) -end - -*(A::ITensor) = A - -ITensors.noncommoninds(A::ITensor) = inds(A) - # TODO: implement something like this? #function sqrt(::Order{2}, T::ITensor) #end @@ -161,7 +122,8 @@ function Base.sqrt(T::ITensor; ishermitian=true, atol=1e-15) if isdiag(T) && order(T) == 2 return itensor(sqrt(tensor(T))) end - U′, D, Uᴴ = eigendecomp(T; ishermitian=ishermitian) + #U′, D, Uᴴ = eigendecomp(T; ishermitian=ishermitian) + D, U = eigen(T; ishermitian=ishermitian) # XXX: if T is order 2 and diagonal, D may just be a view # of T so this would also modify T #D .= sqrt.(D) @@ -174,7 +136,7 @@ function Base.sqrt(T::ITensor; ishermitian=true, atol=1e-15) sqrtD[n, n] = sqrt(Dnn) end end - return U′ * sqrtD * Uᴴ + return U' * sqrtD * dag(U) end ############################################################################ @@ -183,14 +145,4 @@ end # TODO: make this definition AbstractMPS # Handle orthogonality center correctly -Base.getindex(ψ::MPS, r::UnitRange{Int}) = MPS([ψ[n] for n in r]) - -#TODO Remove if everything is working nicely -#Was still crashing on my laptop after updating ITensors -Base.fill!(::NDTensors.NoData, ::Any) = NDTensors.NoData() - -function ITensors.NDTensors.contraction_output( - A::NDTensors.EmptyTensor, B::NDTensors.DiagBlockSparseTensor, label -) - return NDTensors.EmptyTensor(promote_type(eltype(A), eltype(B)), label) -end +Base.getindex(ψ::MPS, r::UnitRange{Int}) = MPS([ψ[n] for n in r]) # added From a70d54ad8f19467ae9eb8be05e675f605b8d4571 Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Mon, 14 Oct 2024 15:30:33 -0400 Subject: [PATCH 2/5] Update README --- README.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b5f064cb..049e343c 100644 --- a/README.md +++ b/README.md @@ -21,33 +21,32 @@ This package is a work in progress. Here are some examples of the interface: julia> using ITensors, ITensorMPS, ITensorInfiniteMPS julia> s = siteinds("S=1/2", 3) -3-element Array{Index{Int64},1}: - (dim=2|id=652|"S=1/2,Site,n=1") - (dim=2|id=984|"S=1/2,Site,n=2") - (dim=2|id=569|"S=1/2,Site,n=3") +3-element Vector{Index{Int64}}: + (dim=2|id=988|"S=1/2,Site,n=1") + (dim=2|id=220|"S=1/2,Site,n=2") + (dim=2|id=650|"S=1/2,Site,n=3") julia> ψ = InfiniteMPS(s) # Infinite MPS with 3-site unit cell InfiniteMPS -[1] IndexSet{3} (dim=1|id=317|"Link,c=0,l=3") (dim=2|id=652|"S=1/2,Site,c=1,n=1") (dim=1|id=77|"Link,c=1,l=1") -[2] IndexSet{3} (dim=1|id=77|"Link,c=1,l=1") (dim=2|id=984|"S=1/2,Site,c=1,n=2") (dim=1|id=868|"Link,c=1,l=2") -[3] IndexSet{3} (dim=1|id=868|"Link,c=1,l=2") (dim=2|id=569|"S=1/2,Site,c=1,n=3") (dim=1|id=317|"Link,c=1,l=3") - +[1] ((dim=1|id=108|"Link,c=0,l=3"), (dim=2|id=988|"S=1/2,Site,c=1,n=1"), (dim=1|id=112|"Link,c=1,l=1")) +[2] ((dim=1|id=112|"Link,c=1,l=1"), (dim=2|id=220|"S=1/2,Site,c=1,n=2"), (dim=1|id=429|"Link,c=1,l=2")) +[3] ((dim=1|id=429|"Link,c=1,l=2"), (dim=2|id=650|"S=1/2,Site,c=1,n=3"), (dim=1|id=108|"Link,c=1,l=3")) julia> ψ[2] == replacetags(ψ[5], "c=2" => "c=1") # Indexing outside of the unit cell gets tensors from other unit cells true julia> ψ₁ = ψ[1:3] # Create a finite MPS from the tensors of the first unit cell MPS -[1] IndexSet{3} (dim=1|id=317|"Link,c=0,l=3") (dim=2|id=652|"S=1/2,Site,c=1,n=1") (dim=1|id=77|"Link,c=1,l=1") -[2] IndexSet{3} (dim=1|id=77|"Link,c=1,l=1") (dim=2|id=984|"S=1/2,Site,c=1,n=2") (dim=1|id=868|"Link,c=1,l=2") -[3] IndexSet{3} (dim=1|id=868|"Link,c=1,l=2") (dim=2|id=569|"S=1/2,Site,c=1,n=3") (dim=1|id=317|"Link,c=1,l=3") +[1] ((dim=1|id=108|"Link,c=0,l=3"), (dim=2|id=988|"S=1/2,Site,c=1,n=1"), (dim=1|id=112|"Link,c=1,l=1")) +[2] ((dim=1|id=112|"Link,c=1,l=1"), (dim=2|id=220|"S=1/2,Site,c=1,n=2"), (dim=1|id=429|"Link,c=1,l=2")) +[3] ((dim=1|id=429|"Link,c=1,l=2"), (dim=2|id=650|"S=1/2,Site,c=1,n=3"), (dim=1|id=108|"Link,c=1,l=3")) julia> ψ₂ = ψ[4:6] # Create a finite MPS from the tensors of the second unit cell MPS -[1] IndexSet{3} (dim=1|id=317|"Link,c=1,l=3") (dim=2|id=652|"S=1/2,Site,c=2,n=1") (dim=1|id=77|"Link,c=2,l=1") -[2] IndexSet{3} (dim=1|id=77|"Link,c=2,l=1") (dim=2|id=984|"S=1/2,Site,c=2,n=2") (dim=1|id=868|"Link,c=2,l=2") -[3] IndexSet{3} (dim=1|id=868|"Link,c=2,l=2") (dim=2|id=569|"S=1/2,Site,c=2,n=3") (dim=1|id=317|"Link,c=2,l=3") +[1] ((dim=1|id=108|"Link,c=1,l=3"), (dim=2|id=988|"S=1/2,Site,c=2,n=1"), (dim=1|id=112|"Link,c=2,l=1")) +[2] ((dim=1|id=112|"Link,c=2,l=1"), (dim=2|id=220|"S=1/2,Site,c=2,n=2"), (dim=1|id=429|"Link,c=2,l=2")) +[3] ((dim=1|id=429|"Link,c=2,l=2"), (dim=2|id=650|"S=1/2,Site,c=2,n=3"), (dim=1|id=108|"Link,c=2,l=3")) ``` Useful operations like gauging and optimization are in progress, so stay tuned! From e201ad1c8b869a94f34fbf9f273e274b1be6a7b8 Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Mon, 14 Oct 2024 15:34:57 -0400 Subject: [PATCH 3/5] Formatting --- src/ITensors.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ITensors.jl b/src/ITensors.jl index 9e919a8a..dee0fecd 100644 --- a/src/ITensors.jl +++ b/src/ITensors.jl @@ -34,7 +34,6 @@ Base.keys(ts::TagSet) = Base.OneTo(length(ts)) # added import ITensors: Tag, commontags - maxlength(tag::Tag) = length(tag.data) # added function Base.length(tag::Tag) # added From 193f7a45ea053ea034d3f0c2e2c51153d5ee7b5f Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Mon, 17 Feb 2025 20:21:00 -0500 Subject: [PATCH 4/5] Rename Comment --- src/ITensors.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ITensors.jl b/src/ITensors.jl index dee0fecd..8c8894ea 100644 --- a/src/ITensors.jl +++ b/src/ITensors.jl @@ -30,13 +30,13 @@ end # # Used for findfirst -Base.keys(ts::TagSet) = Base.OneTo(length(ts)) # added +Base.keys(ts::TagSet) = Base.OneTo(length(ts)) # TODO: to remove import ITensors: Tag, commontags -maxlength(tag::Tag) = length(tag.data) # added +maxlength(tag::Tag) = length(tag.data) # TODO: to remove -function Base.length(tag::Tag) # added +function Base.length(tag::Tag) # TODO: to remove n = 1 while n <= maxlength(tag) && tag[n] != zero(eltype(tag)) n += 1 @@ -44,7 +44,7 @@ function Base.length(tag::Tag) # added return n - 1 end -Base.lastindex(tag::Tag) = length(tag) # added +Base.lastindex(tag::Tag) = length(tag) # TODO: to remove Base.getindex(tag::Tag, r::UnitRange) = Tag([tag[n] for n in r]) #added @@ -144,4 +144,4 @@ end # TODO: make this definition AbstractMPS # Handle orthogonality center correctly -Base.getindex(ψ::MPS, r::UnitRange{Int}) = MPS([ψ[n] for n in r]) # added +Base.getindex(ψ::MPS, r::UnitRange{Int}) = MPS([ψ[n] for n in r]) # TODO: to remove From 6bba948c443289a399d1fc6f797219b6e8bf9a62 Mon Sep 17 00:00:00 2001 From: Ryan Levy Date: Tue, 18 Feb 2025 09:39:01 -0500 Subject: [PATCH 5/5] Bump version and bump ITensors compat --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 18c13efa..71d3b202 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensorInfiniteMPS" uuid = "1dc1fb26-a137-4954-ae60-1bd4106e95ad" authors = ["Matthew Fishman and contributors"] -version = "0.1.0" +version = "0.2.0" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" @@ -20,7 +20,7 @@ SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66" Compat = "3, 4" HDF5 = "0.15, 0.16, 0.17" ITensorMPS = "0.3" -ITensors = "0.7" +ITensors = "0.7, 0.8" Infinities = "0.1" IterTools = "1" KrylovKit = "0.5, 0.6, 0.7, 0.8"