Skip to content

Commit e50abc6

Browse files
authored
Add MultilineMPO space getters (#407)
* add space definitions for multilineMPO * add tests
1 parent 888de7e commit e50abc6

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/operators/multilinempo.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ function Base.:*(mpo1::MultilineMPO, mpo2::MultilineMPO)
4343
size(mpo1) == size(mpo2) || throw(ArgumentError("dimension mismatch"))
4444
return Multiline(map(*, zip(mpo1, mpo2)))
4545
end
46+
47+
for f_space in (:physicalspace, :left_virtualspace, :right_virtualspace)
48+
@eval $f_space(t::MultilineMPO, i::Int, j::Int) = $f_space(t[i], j)
49+
@eval $f_space(t::MultilineMPO, I::CartesianIndex{2}) = $f_space(t, Tuple(I)...)
50+
@eval $f_space(t::MultilineMPO) = map(Base.Fix1($f_space, t), eachindex(t))
51+
end

test/operators/mpo.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ end
8686

8787
@testset "InfiniteMPO" begin
8888
P =^2
89+
V =^2
8990
T = Float64
9091

91-
H1 = randn(T, P P)
92-
H1 += H1'
92+
H1 = randn(T, V P P V)
9393
H = InfiniteMPO([H1])
9494

9595
@test !isfinite(H)
@@ -98,6 +98,16 @@ end
9898
@test GeometryStyle(H) == InfiniteChainStyle()
9999
@test OperatorStyle(typeof(H)) == MPOStyle()
100100
@test OperatorStyle(H) == MPOStyle()
101+
102+
@test physicalspace(H, 1) == P
103+
@test left_virtualspace(H, 1) == V
104+
@test left_virtualspace(H, 4) == V
105+
@test right_virtualspace(H, 1) == V
106+
107+
multiH = MultilineMPO([H, H])
108+
@test physicalspace(multiH, 1, 1) == P
109+
@test left_virtualspace(multiH, 1, 1) == left_virtualspace(multiH, 2, 1) == V
110+
@test right_virtualspace(multiH, CartesianIndex(1, 2)) == V
101111
end
102112

103113
@testset "Adapt" for V in (ℂ^2, U1Space(-1 => 1, 0 => 1, 1 => 1))

0 commit comments

Comments
 (0)