Skip to content

Commit b89ca23

Browse files
Fix error noticed by @Nicoljno
1 parent abb71af commit b89ca23

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/approximations.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
abstract type ApproximationQuantumStates{T} end
2+
# It is easy to get confused between the approximations of:
3+
# - the state space, i.e., all mixed states
4+
# - the complex sphere, i.e., all pure states
5+
# - the real sphere
6+
# In this file, η is the shrinking factor wrt the state space, while shr is the shrinking factor wrt the real sphere.
7+
# For qubits, the Bloch sphere identifies exactly the state space with the 3D sphere, i.e., η = shr.
8+
# In general, we resort to Alice and Bob meet Banach, Lemma 9.2 to get η = 2shr^2 - 1.
29

310
"""
411
PolytopeReducedComplexSphere{T} <: ApproximationQuantumStates{T}
@@ -14,9 +21,10 @@ end
1421
export PolytopeReducedComplexSphere
1522

1623
function PolytopeReducedComplexSphere{T}(mat::Matrix, shr) where {T <: Real}
17-
@assert isodd(length(size(mat, 2)))
24+
@assert isodd(size(mat, 2))
1825
d = (size(mat, 2) + 1) ÷ 2
19-
return PolytopeReducedComplexSphere{T}(2shr^2 - 1, d, 0, mat)
26+
η = d == 2 ? shr : 2shr^2 - 1
27+
return PolytopeReducedComplexSphere{T}(η, d, 0, mat)
2028
end
2129

2230
Base.length(A::PolytopeReducedComplexSphere) = size(A.mat, 1)
@@ -55,7 +63,8 @@ function PolytopePhasedComplexSphere{T}(mat::Matrix, shr, n) where {T <: Real}
5563
ind = ones(Int, d)
5664
base = [size(mat, 1); fill(n, d - 1)]
5765
sc = sincos.((T(pi) / n) * (0:n-1))
58-
return PolytopePhasedComplexSphere{T}(2shr^2 - 1, d, 0, mat, n, ind, base, sc)
66+
η = d == 2 ? shr : 2shr^2 - 1
67+
return PolytopePhasedComplexSphere{T}(η, d, 0, mat, n, ind, base, sc)
5968
end
6069

6170
Base.length(A::PolytopePhasedComplexSphere) = size(A.mat, 1) * A.n^(A.d - 1)
@@ -97,10 +106,11 @@ function CrossPolytopeSubdivision{T}(d::Integer; max_length = 10^6) where {T <:
97106
end
98107

99108
function CrossPolytopeSubdivision{T}(d::Integer, n::Integer) where {T <: Real}
100-
η = n / sqrt(T(n^2 + (d 3 ? 1 : 2) * (d - 1)))
109+
shr = n / sqrt(T(n^2 + (d 2 ? 1 : 2) * (2d - 2)))
101110
vec = fill(1, 2d - 1)
102111
vec[2d-1] = n + 1
103112
sgn = fill(Int8(-1), 2d - 2)
113+
η = d == 2 ? shr : 2shr^2 - 1
104114
return CrossPolytopeSubdivision{T}(η, d, 0, n, vec, sgn)
105115
end
106116

0 commit comments

Comments
 (0)