Skip to content

Commit

Permalink
Improve InfiniteMPOMatrix, rename to InfiniteBlockMPO (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerviou authored Sep 13, 2023
1 parent 1f19fd1 commit d35574b
Show file tree
Hide file tree
Showing 13 changed files with 861 additions and 284 deletions.
6 changes: 3 additions & 3 deletions src/ITensorInfiniteMPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ include("itensormap.jl")
include("celledvectors.jl")
include("abstractinfinitemps.jl")
include("infinitemps.jl")
include("infinitempo.jl")
include("infinitecanonicalmps.jl")
include("infinitempomatrix.jl")
include("infiniteblockmpo.jl")
include("infinitempo.jl")
include("transfermatrix.jl")
include("models/models.jl")
include("models/fqhe13.jl")
Expand All @@ -60,7 +60,7 @@ export Cell,
InfMPS,
InfiniteSum,
InfiniteMPO,
InfiniteMPOMatrix,
InfiniteBlockMPO,
InfiniteSumLocalOps,
ITensorMap,
ITensorNetwork,
Expand Down
10 changes: 10 additions & 0 deletions src/ITensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,13 @@ 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
7 changes: 6 additions & 1 deletion src/celledvectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ _setindex_cell1!(cv::CelledVector, val, n::Int) = (ITensors.data(cv)[n] = val)
function getindex(cv::CelledVector, n::Int)
cellₙ = cell(cv, n)
siteₙ = cellindex(cv, n)
cellₙ == 1 && return _getindex_cell1(cv, siteₙ) #Avoid unnecessary calls
return translatecell(cv.translator, _getindex_cell1(cv, siteₙ), cellₙ - 1)
end

Expand Down Expand Up @@ -169,7 +170,11 @@ getindex(cv::CelledVector, c::Cell) = cv[eachindex(cv, c)]
function setindex!(cv::CelledVector, T, n::Int)
cellₙ = cell(cv, n)
siteₙ = cellindex(cv, n)
_setindex_cell1!(cv, translatecell(cv.translator, T, -(cellₙ - 1)), siteₙ)
if cellₙ == 1
_setindex_cell1!(cv, T, siteₙ)
else
_setindex_cell1!(cv, translatecell(cv.translator, T, -(cellₙ - 1)), siteₙ)
end
return cv
end

Expand Down
Loading

0 comments on commit d35574b

Please sign in to comment.