Skip to content

Commit

Permalink
Avoid adding SparseBlockTensorMap slices in TaylorCluster impleme…
Browse files Browse the repository at this point in the history
…ntation
  • Loading branch information
leburgel committed Jan 20, 2025
1 parent 0a667fa commit 529ede7
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/algorithms/timestep/timeevmpo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,20 @@ function make_time_mpo(H::MPOHamiltonian, dt::Number, alg::TaylorCluster;
n1 = count(==(1), c.I)
n3 = count(==(V), c.I)

if n3 <= n1 && s_c != c
slice[linds[s_c], 1, 1, :] += slice[c_lin, 1, 1, :]
for I in nonzero_keys(slice)
(I[1] == c_lin || I[4] == c_lin) && delete!(slice, I)
if n3 <= n1 && s_c != c || n3 > n1 && s_r != c
if n3 <= n1 && s_c != c
for k in 1:size(slice, 4)
if CartesianIndex(c_lin, 1, 1, k) in nonzero_keys(slice)
slice[linds[s_c], 1, 1, k] += slice[c_lin, 1, 1, k]

Check warning on line 137 in src/algorithms/timestep/timeevmpo.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/timeevmpo.jl#L133-L137

Added lines #L133 - L137 were not covered by tests
end
end
elseif n3 > n1 && s_r != c
for k in 1:size(slice, 1)
if CartesianIndex(k, 1, 1, c_lin) in nonzero_keys(slice)
slice[k, 1, 1, linds[s_r]] += slice[k, 1, 1, c_lin]

Check warning on line 143 in src/algorithms/timestep/timeevmpo.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/timeevmpo.jl#L139-L143

Added lines #L139 - L143 were not covered by tests
end
end

Check warning on line 145 in src/algorithms/timestep/timeevmpo.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/timeevmpo.jl#L145

Added line #L145 was not covered by tests
end
elseif n3 > n1 && s_r != c
slice[:, 1, 1, linds[s_r]] += slice[:, 1, 1, c_lin]
for I in nonzero_keys(slice)
(I[1] == c_lin || I[4] == c_lin) && delete!(slice, I)
end
Expand All @@ -154,7 +161,11 @@ function make_time_mpo(H::MPOHamiltonian, dt::Number, alg::TaylorCluster;
b = CartesianIndex(replace(a.I, V => 1))
b_lin = linds[b]
factor = τ^n1 * factorial(N - n1) / factorial(N)
slice[:, 1, 1, b_lin] += factor * slice[:, 1, 1, a_lin]
for k in 1:size(slice, 1)
if CartesianIndex(k, 1, 1, a_lin) in nonzero_keys(slice)
slice[k, 1, 1, b_lin] += factor * slice[k, 1, 1, a_lin]

Check warning on line 166 in src/algorithms/timestep/timeevmpo.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/timeevmpo.jl#L164-L166

Added lines #L164 - L166 were not covered by tests
end
end

Check warning on line 168 in src/algorithms/timestep/timeevmpo.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/timeevmpo.jl#L168

Added line #L168 was not covered by tests

for I in nonzero_keys(slice)
(I[1] == a_lin || I[4] == a_lin) && delete!(slice, I)
Expand Down

0 comments on commit 529ede7

Please sign in to comment.