Skip to content

Commit

Permalink
better read the type from the parameter than to ask for it explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoms committed Jun 26, 2024
1 parent 40e69d7 commit 4c1698c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function phiplus(::Type{T}, d::Integer = 2) where {T<:Number}
return LA.Hermitian(psi * psi' / T(d))
end
phiplus(d::Integer = 2) = phiplus(ComplexF64, d)
export phiplus # SD: maybe call it ϕ_plus or even ϕp? There is also φ potentially.
export phiplus

"Produces the maximally entangled state ψ⁻ of local dimension `d`"
function psiminus(::Type{T}, d::Integer = 2) where {T<:Number}
Expand All @@ -18,18 +18,16 @@ function psiminus(::Type{T}, d::Integer = 2) where {T<:Number}
return LA.Hermitian(psi * psi' / T(d))
end
psiminus(d::Integer = 2) = psiminus(ComplexF64, d)
export psiminus # SD: maybe call it ψ_minus or even ψm?
export psiminus

"Produces the isotropic state of local dimension `d` with visibility `v`"
function isotropic(::Type{T}, v::Real = 1.0, d::Integer = 2) where {T<:Number}
function isotropic(v::T, d::Integer = 2) where {T<:Real}
return LA.Hermitian(v * phiplus(T, d) + (1 - v) * LA.I(d^2) / T(d^2))
end
isotropic(v::Real = 1.0, d::Integer = 2) = isotropic(ComplexF64, v, d)
export isotropic

"Produces the anti-isotropic state of local dimension `d` with visibility `v`"
function anti_isotropic(::Type{T}, v::Real = 1.0, d::Integer = 2) where {T<:Number}
function anti_isotropic(v::T, d::Integer = 2) where {T<:Real}
return LA.Hermitian(v * psiminus(T, d) + (1 - v) * LA.I(d^2) / T(d^2))
end
anti_isotropic(v::Real = 1.0, d::Integer = 2) = anti_isotropic(ComplexF64, v, d)
export anti_isotropic
4 changes: 2 additions & 2 deletions test/nonlocal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
end
@testset "FP and FC notations" begin
Aax = povm(mub(2))
@test correlation_tensor(isotropic(), Aax, Aax) Diagonal([1, 1, -1, 1])
@test correlation_tensor(isotropic(), Aax, Aax; marg = false) Diagonal([1, 1, -1])
@test correlation_tensor(isotropic(1.0), Aax, Aax) Diagonal([1, 1, -1, 1])
@test correlation_tensor(isotropic(1.0), Aax, Aax; marg = false) Diagonal([1, 1, -1])
end

0 comments on commit 4c1698c

Please sign in to comment.