Skip to content

Commit 93a24a8

Browse files
committed
introduce hellinger_dist
1 parent 47e37e3 commit 93a24a8

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

docs/src/resources/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ entanglement
262262
fidelity
263263
tracedist
264264
hilbert_dist
265+
hellinger_dist
265266
bures_dist
266267
bures_angle
267268
```

docs/src/resources/bibliography.bib

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,11 @@ @article{Vedral-Plenio1998
9696
doi = {10.1103/PhysRevA.57.1619},
9797
url = {https://link.aps.org/doi/10.1103/PhysRevA.57.1619}
9898
}
99+
100+
@article{Spehner2017,
101+
title={Geometric measures of quantum correlations with Bures and Hellinger distances},
102+
author={D. Spehner and F. Illuminati and M. Orszag and W. Roga},
103+
year={2017},
104+
journal={arXiv:1611.03449},
105+
url={https://arxiv.org/abs/1611.03449},
106+
}

src/metrics.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Functions for calculating metrics (distance measures) between states and operato
33
=#
44

55
export fidelity
6-
export tracedist, hilbert_dist
6+
export tracedist, hilbert_dist, hellinger_dist
77
export bures_dist, bures_angle
88

99
@doc raw"""
@@ -65,6 +65,33 @@ function hilbert_dist(
6565
return tr(A' * A)
6666
end
6767

68+
@doc raw"""
69+
hellinger_dist(ρ::QuantumObject, σ::QuantumObject)
70+
71+
Calculates the [Hellinger distance](https://en.wikipedia.org/wiki/Hellinger_distance) between two [`QuantumObject`](@ref):
72+
``D_H(\hat{\rho}, \hat{\sigma}) = \sqrt{2 - 2 \textrm{Tr}\left(\sqrt{\hat{\rho}}\sqrt{\hat{\sigma}}\right)}``
73+
74+
Note that `ρ` and `σ` must be either [`Ket`](@ref) or [`Operator`](@ref).
75+
76+
# References
77+
- [Spehner2017](@citet)
78+
"""
79+
function hellinger_dist(
80+
ρ::QuantumObject{ObjType1},
81+
σ::QuantumObject{ObjType2},
82+
) where {
83+
ObjType1<:Union{KetQuantumObject,OperatorQuantumObject},
84+
ObjType2<:Union{KetQuantumObject,OperatorQuantumObject},
85+
}
86+
# Ket (pure state) doesn't need to do square root
87+
sqrt_ρ =isa KetQuantumObject) ? ket2dm(ρ) : sqrt(ρ)
88+
sqrt_σ =isa KetQuantumObject) ? ket2dm(σ) : sqrt(σ)
89+
90+
# `max` is to avoid numerical instabilities
91+
# it happens when ρ = σ, sum(eigvals) might be slightly larger than 1
92+
return sqrt(2.0 * max(0.0, 1.0 - sum(real, eigvals(sqrt_ρ * sqrt_σ))))
93+
end
94+
6895
@doc raw"""
6996
bures_dist(ρ::QuantumObject, σ::QuantumObject)
7097

0 commit comments

Comments
 (0)