Skip to content

Commit

Permalink
Removed automul
Browse files Browse the repository at this point in the history
  • Loading branch information
shinaoka committed Nov 26, 2024
1 parent 192b26d commit ea068e1
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 345 deletions.
3 changes: 0 additions & 3 deletions src/PartitionedMPSs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ include("patching.jl")
include("contract.jl")
include("adaptivemul.jl")

# Only for backward compatibility
include("automul.jl")

end
124 changes: 0 additions & 124 deletions src/automul.jl

This file was deleted.

58 changes: 0 additions & 58 deletions src/bak/conversion.jl

This file was deleted.

38 changes: 0 additions & 38 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,41 +105,3 @@ function rearrange_siteinds(M::AbstractMPS, sites::Vector{Vector{Index{T}}})::MP
tensors[end] *= t
return MPS(tensors)
end

function _extract_diagonal(t, site::Index{T}, site2::Index{T}) where {T<:Number}
dim(site) == dim(site2) || error("Dimension mismatch")
restinds = uniqueinds(inds(t), site, site2)
newdata = zeros(eltype(t), dim.(restinds)..., dim(site))
olddata = Array(t, restinds..., site, site2)
for i in 1:dim(site)
newdata[.., i] = olddata[.., i, i]
end
return ITensor(newdata, restinds..., site)
end

"""
Makes an MPS/MPO diagonal for a specified a site index `s`.
On return, the data will be deep copied and the target core tensor will be diagonalized with an additional site index `s'`.
"""
function makesitediagonal(M::AbstractMPS, site::Index{T})::MPS where {T}
M_ = deepcopy(MPO(collect(M)))

target_site::Int = only(findsites(M_, site))
M_[target_site] = _asdiagonal(M_[target_site], site)

return MPS(collect(M_))
end

function makesitediagonal(M::AbstractMPS, tag::String)::MPS
M_ = deepcopy(MPO(collect(M)))
sites = siteinds(M_)

target_positions = findallsites_by_tag(siteinds(M_); tag=tag)

for t in eachindex(target_positions)
i, j = target_positions[t]
M_[i] = _asdiagonal(M_[i], sites[i][j])
end

return MPS(collect(M_))
end
73 changes: 0 additions & 73 deletions test/automul_tests.jl

This file was deleted.

49 changes: 0 additions & 49 deletions test/util_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,4 @@ import FastMPOContractions as FMPOC
@test reduce(*, MPS(prjΨ1)) reduce(*, MPS(prjΨ1_rearranged))
@test PartitionedMPSs.siteinds(prjΨ1_rearranged) == sites_rearranged
end

@testset "makesitediagonal and extractdiagonal" begin
N = 3
sitesx = [Index(2, "x=$n") for n in 1:N]
sitesy = [Index(2, "y=$n") for n in 1:N]
sitesz = [Index(2, "z=$n") for n in 1:N]

sitesxy_vec = [[x, y] for (x, y) in zip(sitesx, sitesy)]
sitesz_vec = [[z] for z in sitesz]
sites = [x for pair in zip(sitesxy_vec, sitesz_vec) for x in pair]

Ψ = MPS(collect(_random_mpo(sites)))

prjΨ = SubDomainMPS(Ψ)
prjΨ1 = project(prjΨ, Dict(sitesx[1] => 1))

prjΨ1_diagonalz = makesitediagonal(prjΨ1, "y")
sites_diagonalz = Iterators.flatten(siteinds(prjΨ1_diagonalz))

psi_diag = prod(prjΨ1_diagonalz.data)
psi = prod(prjΨ1.data)

@test extractdiagonal(prjΨ1_diagonalz, "y") prjΨ1

for indval in eachindval(sites_diagonalz...)
ind = first.(indval)
val = last.(indval)

index_dict = Dict{Index{Int},Vector{Int}}()
for (i, el) in enumerate(ind)
baseind = noprime(el)
if haskey(index_dict, baseind)
push!(index_dict[baseind], i)
else
index_dict[baseind] = [i]
end
end
repeated_indices = [is for is in values(index_dict) if length(is) > 1]

isdiagonalelement = all(allequal(val[i] for i in is) for is in repeated_indices)

if isdiagonalelement
nondiaginds = unique(noprime(i) => v for (i, v) in indval)
@test psi_diag[indval...] == psi[nondiaginds...]
else
@test iszero(psi_diag[indval...])
end
end
end
end

0 comments on commit ea068e1

Please sign in to comment.