Skip to content

Commit

Permalink
Merge pull request #252 from LHerviou/Temp_Improving
Browse files Browse the repository at this point in the history
Adding the small fix. It should just be integrated in ITensors.
  • Loading branch information
LHerviou authored Jul 3, 2023
2 parents ca08705 + d9bdba5 commit aafb7e2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
16 changes: 9 additions & 7 deletions src/ITensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,16 @@ end
# Handle orthogonality center correctly
Base.getindex::MPS, r::UnitRange{Int}) = MPS([ψ[n] for n in r])

Base.zero(T::ITensor) = false * T

function ITensors.NDTensors.datatype(
::ITensors.EmptyStorage{Float64,ITensors.NDTensors.BlockSparse{Float64,Vector{Float64},N}}
) where {N}
return Vector{Float64}
end
# Base.zero(T::ITensor) = false * T
#
# function ITensors.NDTensors.datatype(
# ::ITensors.EmptyStorage{Float64,ITensors.NDTensors.BlockSparse{Float64,Vector{Float64},N}}
# ) where {N}
# return Vector{Float64}
# end
#
# function ITensors.NDTensors.datatype(T::ITensors.NDTensors.TensorStorage{Float64})
# return typeof(data(T))
# end

Base.fill!(::NDTensors.NoData, ::Any) = 0
10 changes: 0 additions & 10 deletions src/infinitempo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ function cat_to_itensor(Hm::Matrix{ITensor})
end
append!(input, [Hm[x, ly] * onehot(T, right_links[ly] => 1) => right_links[ly]])
H, ir = directsum(input...; tags="Link, right")
# H, ir = directsum(
# [((y == 1 || y == ly) ? Hm[x, y] * onehot(T, right_links[y] => 1) : Hm[x, y]) =>
# right_links[y] for y in 1:ly]...;
# tags="Link, right",
# )
if x == 1
append!(new_rs, [ir])
else
Expand All @@ -62,11 +57,6 @@ function cat_to_itensor(Hm::Matrix{ITensor})
end
append!(input, [Ls[lx] * onehot(T, left_links[lx] => 1) => left_links[lx]])
H, new_l = directsum(input...; tags="Link, left")
# H, new_l = directsum(
# [((x == 1 || x == lx) ? Ls[x] * onehot(T, left_links[x] => 1) : Ls[x]) => left_links[x] for
# x in 1:lx]...;
# tags="Link, left",
# )
return H, new_l, new_rs[1]
end
#
Expand Down
24 changes: 12 additions & 12 deletions src/infinitempomatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ function apply_tensor(A::Array{ITensor,N}, B::ITensor...) where {N}
return new_A
end

import ITensors._add
function ITensors._add(
A::T1, B::T2
) where {T1<:ITensors.NDTensors.EmptyTensor,T2<:ITensors.NDTensors.EmptyTensor}
ndims(A) != ndims(B) && throw(
ITensors.DimensionMismatch("cannot add ITensors with different numbers of indices")
)
indices = inds(A)
length(commoninds(indices, B)) != length(inds(B)) &&
error("cannot add ITensors with different indices")
return ITensor(promote_type(eltype(A), eltype(B)), indices)
end
# import ITensors._add
# function ITensors._add(
# A::T1, B::T2
# ) where {T1<:ITensors.NDTensors.EmptyTensor,T2<:ITensors.NDTensors.EmptyTensor}
# ndims(A) != ndims(B) && throw(
# ITensors.DimensionMismatch("cannot add ITensors with different numbers of indices")
# )
# indices = inds(A)
# length(commoninds(indices, B)) != length(inds(B)) &&
# error("cannot add ITensors with different indices")
# return ITensor(promote_type(eltype(A), eltype(B)), indices)
# end

0 comments on commit aafb7e2

Please sign in to comment.