Skip to content

Commit b616cdd

Browse files
committed
minor fix and improving tests
1 parent 2815a49 commit b616cdd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/entanglement.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ julia> entanglement_entropy(s, [1,4], Val(:graph))
263263
1
264264
```
265265
266-
Based on [hein2006entanglement](@ref).
267-
"""
266+
Based on "Entanglement in graph states and its applications".
267+
""" # TODO you should use [hein2006entanglement](@cite) instead of "Entanglement in graph states and its applications", but Documenter is giving the weirdest error if you do so...
268268
function entanglement_entropy(state::AbstractStabilizer, subsystem::AbstractVector, algorithm::Val{:graph})
269269
graph = Graphs.Graph(state)
270270
adjmat = Graphs.adjacency_matrix(graph)
@@ -325,7 +325,7 @@ given by `Iⁿ(𝒶, 𝒷) = Sⁿ𝒶 + Sⁿ𝒷 - Sⁿ𝒶𝒷`, where the Rén
325325
Clifford circuits, all Renyi entropies are equal due to the flat entanglement spectrum.
326326
327327
```jldoctest
328-
julia> mutual_information(ghz(3), 1:2, 3:5, Val(:clip))
328+
julia> mutual_information(ghz(3), 1:2, 3:4, Val(:clip))
329329
2
330330
```
331331
@@ -351,7 +351,7 @@ julia> s = Stabilizer(Graph(ghz(4)))
351351
+ Z__X
352352
353353
julia> mutual_information(s, [1,2], [3, 4], Val(:graph))
354-
0
354+
2
355355
```
356356
357357
"""
@@ -360,9 +360,11 @@ function mutual_information(state::AbstractStabilizer, A::AbstractVector, B::Abs
360360
S𝒶 = entanglement_entropy(state, A, algorithm)
361361
S𝒷 = entanglement_entropy(state, B, algorithm)
362362
S𝒶𝒷 = entanglement_entropy(state, union(A, B), algorithm)
363+
return S𝒶 + S𝒷 - S𝒶𝒷
363364
else
364365
S𝒶 = entanglement_entropy(state, A, algorithm; pure=pure)
365366
S𝒷 = entanglement_entropy(state, B, algorithm; pure=pure)
366367
S𝒶𝒷 = entanglement_entropy(state, union(A, B), algorithm; pure=pure)
368+
return S𝒶 + S𝒷 - S𝒶𝒷
367369
end
368370
end

test/test_entanglement.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
startB = rand(subsystem_rangeA)
6060
endB = rand(startB:n)
6161
subsystem_rangeB = startB:endB
62+
@test mutual_information(copy(s), subsystem_rangeA, subsystem_rangeB, Val(:clip)) == mutual_information(copy(s), subsystem_rangeA, subsystem_rangeB, Val(:rref)) == mutual_information(copy(s), subsystem_rangeA, subsystem_rangeB, Val(:graph))
6263
# The mutual information `Iⁿ(𝒶, 𝒷) = Sⁿ𝒶 + Sⁿ𝒷 - Sⁿ𝒶𝒷 for Clifford circuits is non-negative since n is 1 [li2019measurement](@cite).
6364
@test mutual_information(copy(s), subsystem_rangeA, subsystem_rangeB, Val(:clip)) & mutual_information(copy(s), subsystem_rangeA, subsystem_rangeB, Val(:rref)) >= 0
6465
@test mutual_information(copy(s), subsystem_rangeA, subsystem_rangeB, Val(:graph)) >= 0

0 commit comments

Comments
 (0)