List of functions
Basic
Ket.ketbra — Function
ketbra(v::AbstractVector)Produces a ketbra of vector v.
Ket.shift — Function
shift([T=ComplexF64,] d::Integer, p::Integer = 1)Constructs the shift operator X of dimension d to the power p.
Reference: Generalized Clifford algebra
Ket.clock — Function
clock([T=ComplexF64,] d::Integer, q::Integer = 1)Constructs the clock operator Z of dimension d to the power q.
Reference: Generalized Clifford algebra
Ket.shiftclock — Function
shiftclock(v::AbstractVector, p::Integer, q::Integer)Produces X^p * Z^q * v, where X and Z are the shift and clock operators of dimension length(v).
Reference: Generalized Clifford algebra
Ket.pauli — Function
pauli([T=ComplexF64,], ind::Vector{<:Integer})Constructs the Pauli matrices: 0 or "I" for the identity, 1 or "X" for the Pauli X operation, 2 or "Y" for the Pauli Y operator, and 3 or "Z" for the Pauli Z operator. Vectors of integers between 0 and 3 or strings of I, X, Y, Z automatically generate Kronecker products of the corresponding operators.
Ket.gellmann — Function
gellmann([T=ComplexF64,], d::Integer = 3; coeff = √(d/2))Constructs the set G of generalized d-dimensional Gell-Mann matrices normalized such that G₁ = I and Tr(GᵢGⱼ) = d δᵢⱼ. Set coeff = 1 to obtain the generalized Gell-Mann matrices normalized such that G₁ = √(2/d) I and Tr(GᵢGⱼ) = 2 δᵢⱼ.
Reference: Generalizations of Pauli matrices
gellmann([T=ComplexF64,], i::Integer, j::Integer, d::Integer = 3)Constructs the set i,jth Gell-Mann matrix of dimension d.
Reference: Generalizations of Pauli matrices
Ket.gellmann! — Function
gellmann!(res::AbstractMatrix{T}, i::Integer, j::Integer, d::Integer = 3)In-place version of gellmann.
Ket.bloch_vector — Function
bloch_vector(ρ::AbstractMatrix, basis = gellmann(checksquare(ρ)))Returns the coordinates of a d × d hermitian matrix in a specified basis, by default the generalized Gell-Mann basis (see gellmann). For density matrices, the resulting vector v is such that v₁ = 1 and norm(v[2:end]) ≤ √(d-1) (with equality for pure states).
Ket.bloch_operator — Function
bloch_operator(v::AbstractVector, basis = gellmann(isqrt(length(v) + 1)))Produces the operator corresponding to the Bloch vector v.
For qubits with the default basis (Pauli operators):
- if
vhas length3, the output is½(I + v₁σ₁ + v₂σ₂ + v₃σ₃), - if
vhas length4, the output is½(v₁I + v₂σ₁ + v₃σ₂ + v₄σ₃).
In general:
- if
vhas lengthd²-1, the output is(I+v⋅basis[2:end])/d, - if
vhas lenghd², the output isv⋅basis/d.
No checks are performed on the result.
Reference: Eltschka et al. arXiv:2012.00587
Ket.cleanup! — Function
cleanup!(M::AbstractArray{T}; tol = _eps(T))Zeroes out real or imaginary parts of M that are smaller than tol.
Ket.symmetric_projector — Function
symmetric_projector(dim::Integer, n::Integer)Computes the projector onto the symmetric subspace of n copies of a dim-dimensional space.
Reference: Watrous' book, Sec. 7.1.1
Ket.symmetric_isometry — Function
symmetric_isometry(dim::Integer, n::Integer)Computes an isometry that encodes the symmetric subspace of n copies of a dim-dimensional space. Specifically, it maps a vector space of dimension binomial(n + dim -1, dim -1) onto the symmetric subspace of the symmetric subspace of the vector space of dimension dim^n.
Reference: Watrous' book, Sec. 7.1.1
Ket.orthonormal_range — Function
orthonormal_range(A::AbstractMatrix{T}; tol::T=nothing) where {T<:Number}Orthonormal basis for the range of A. When A is sparse and T ∈ [Float64, ComplexF64, Float32, ComplexF32], uses a QR factorization and returns a sparse result, otherwise uses an SVD and returns a dense matrix. Tolerance tol is used to compute the rank and is automatically set if not provided.
Ket.n_body_basis — Function
n_body_basis(
n::Integer,
n_parties::Integer;
sb::AbstractVector{<:AbstractMatrix} = [pauli(1), pauli(2), pauli(3)],
eye::AbstractMatrix = I(size(sb[1], 1))Return the basis of n nontrivial operators acting on n_parties, by default using sparse Pauli matrices.
For example, n_body_basis(2, 3) generates all products of two Paulis and one identity, so ${X ⊗ X ⊗ 1, X ⊗ 1 ⊗ X, ..., X ⊗ Y ⊗ 1, ..., 1 ⊗ Z ⊗ Z}$.
Instead of Paulis, a basis can be provided by the parameter sb, and the identity can be changed with eye.
This function returns a generator, which can then be used e.g. in for loops without fully allocating the entire basis at once. If you need a vector, call collect on it.
Multilinear algebra
Ket.applymap_subsystem — Function
applymap_subsystem(op::AbstractMatrix, ψ::AbstractVector, subsystems::Union{Integer, AbstractVector{<:Integer}}, dims::AbstractVector = _equal_sizes(ρ))Applies the operator op to the subsytem of ρ identified by subsystems, resulting in (op ⊗ I) * ψ. If the argument dims is omitted two equally-sized subsystems are assumed.
applymap_subsystem(K::AbstractVector{<:AbstractMatrix}, ρ::AbstractMatrix, subsystems::Union{Integer, AbstractVector{<:Integer}}, dims::AbstractVector = _equal_sizes(ρ))Applies the Kraus operators in K to the subsytems of ρ identified by subsystems, resulting in ∑ᵢ(K[i] ⊗ I) * ρ * (K[i]' ⊗ I). If the argument dims is omitted two equally-sized subsystems are assumed.
applymap_subsystem(K::AbstractVector{<:AbstractSparseArray}, ρ::AbstractSparseArray, subsystems::Union{Integer, AbstractVector{<:Integer}}, dims::AbstractVector = _equal_sizes(ρ))Applies the sparse Kraus operators in K to the subsytems of a sparse matrix ρ identified by subsystems, resulting in ∑ᵢ(K[i] ⊗ I) * ρ * (K[i]' ⊗ I). If the argument dims is omitted two equally-sized subsystems are assumed.
Ket.partial_trace — Function
partial_trace(X::AbstractMatrix, remove::Union{Integer, AbstractVector{<:Integer}}, dims::AbstractVector = _equal_sizes(X))Takes the partial trace of matrix X with subsystem dimensions dims over the subsystems in remove. If the argument dims is omitted two equally-sized subsystems are assumed.
Ket.partial_transpose — Function
partial_transpose(X::AbstractMatrix, transp::Union{Integer, AbstractVector{<:Integer}}, dims::AbstractVector = _equal_sizes(X))Takes the partial transpose of matrix X with subsystem dimensions dims over the subsystems in transp. If the argument dims is omitted two equally-sized subsystems are assumed.
Ket.permute_systems — Function
permute_systems(X::AbstractVector, perm::AbstractVector, dims::AbstractVector = _equal_sizes(X))Permutes the order of the subsystems of vector X with subsystem dimensions dims according to the permutation perm. If the argument dims is omitted two equally-sized subsystems are assumed.
permute_systems(X::AbstractMatrix, perm::AbstractVector, dims::AbstractVector = _equal_sizes(X))Permutes the order of the subsystems of the square matrix X, which is composed by square subsystems of dimensions dims, according to the permutation perm. If the argument dims is omitted two equally-sized subsystems are assumed.
permute_systems(X::AbstractMatrix, perm::Vector, dims::Matrix)Permutes the order of the subsystems of the matrix X, which is composed by subsystems of dimensions dims, according to the permutation perm. dims should be a n × 2 matrix where dims[i, 1] is the number of rows of subsystem i, and dims[i, 2] is its number of columns.
Ket.permutation_matrix — Function
permutation_matrix(dims::Union{Integer,AbstractVector}, perm::AbstractVector)Unitary that permutes subsystems of dimension dims according to the permutation perm. If dims is an Integer, assumes there are length(perm) subsystems of equal dimensions dims.
Ket.trace_replace — Function
trace_replace(X::AbstractMatrix, replace::Union{Integer, AbstractVector{<:Integer}}, dims::AbstractVector = _equal_sizes(X))Takes the partial trace of matrix X with subsystem dimensions dims over the subsystems in replace and replace them with normalized identity. If the argument dims is omitted two equally-sized subsystems are assumed.
Channels
Ket.applymap — Function
applymap(K::Vector{<:AbstractMatrix}, M::AbstractMatrix)Applies the CP map given by the Kraus operators K to the matrix M. Preserves sparsity.
applymap(Φ::AbstractMatrix, M::AbstractMatrix)Applies the CP map given by the Choi-Jamiołkowski operator Φ to the matrix M. Preserves sparsity.
Ket.applymap! — Function
applymap!(result::AbstractMatrix, K::Vector{<:AbstractMatrix}, M::AbstractMatrix, temp::AbstractMatrix)Applies the CP map given by the Kraus operators K to the matrix M without allocating or wrapping. result and temp must be matrices of size dout × dout and dout × din, where dout, din == size(K[1]).
applymap!(result::AbstractMatrix, Φ::AbstractMatrix, M::AbstractMatrix)Applies the CP map given by the Choi-Jamiołkowski operator Φ to the matrix M without allocating or wrapping. In the symmetric or Hermitian cases only the upper triangular is computed. result must be a matrix of size dout × dout, where size(M, 1) * dout == size(Φ, 1).
Ket.channel_bit_flip — Function
channel_bit_flip(p::Real)Return the Kraus operator representation of the bit flip channel. It applies Pauli-X with probability 1 − p (flip from |0⟩ to |1⟩ and vice versa).
Ket.channel_phase_damping — Function
channel_phase_damping(λ::Real)Return the Kraus operator representation of the phase damping channel. It describes the photon scattering or electron perturbation. 'λ' is the probability being scattered or perturbed (without loss of energy).
Ket.channel_phase_flip — Function
channel_phase_flip(p::Real)Return the Kraus operator representation of the phase flip channel. It applies Pauli-Z with probability 1 − p.
Ket.channel_amplitude_damping — Function
channel_amplitude_damping(γ::Real)Return the Kraus operator representation of the amplitude damping channel. It describes the effect of dissipation to an environment at zero temperature. γ is the probability of the system to decay to the ground state.
Ket.channel_amplitude_damping_generalized — Function
channel_amplitude_damping_generalized(rho::AbstractMatrix, p::Real, γ::Real)Return the Kraus operator representation of the generalized amplitude damping channel. It describes the effect of dissipation to an environment at finite temperature. γ is the probability of the system to decay to the ground state. 1-p can be thought as the energy of the stationary state.
Ket.channel_bit_phase_flip — Function
channel_bit_phase_flip(p::Real)Return the Kraus operator representation of the phase flip channel. It applies Pauli-Y (=iXY) with probability 1 − p.
Ket.channel_depolarizing — Function
channel_depolarizing(v::Real, d::Integer = 2)Return the Kraus operator representation of the depolarizing channel of dimension d. It replaces a single qudit by the completely mixed state with probability '1-v'.
Entanglement
Ket.schmidt_decomposition — Function
schmidt_decomposition(ψ::AbstractVector, dims::AbstractVector = _equal_sizes(ψ))Produces the Schmidt decomposition of ψ with subsystem dimensions dims. If the argument dims is omitted equally-sized subsystems are assumed. Returns the (sorted) Schmidt coefficients λ and isometries U, V such that kron(U', V')*ψ is of Schmidt form.
Reference: Schmidt decomposition
Ket.entanglement_entropy — Function
entanglement_entropy(ψ::AbstractVector, dims::AbstractVector = _equal_sizes(ψ); base = 2)Computes the relative entropy of entanglement of a bipartite pure state ψ with subsystem dimensions dims. If the argument dims is omitted equally-sized subsystems are assumed.
entanglement_entropy(ρ::AbstractMatrix, dims::AbstractVector = _equal_sizes(ρ), n::Integer = 1; verbose = false, base = 2)Lower bounds the relative entropy of entanglement of a bipartite state ρ with subsystem dimensions dims using level n of the DPS hierarchy. If the argument dims is omitted equally-sized subsystems are assumed.
Ket.entanglement_robustness — Function
entanglement_robustness(
ρ::AbstractMatrix{T},
dims::AbstractVector = _equal_sizes(ρ),
n::Integer = 1;
noise::String = "white"
ppt::Bool = true,
inner::Bool = false,
verbose::Bool = false,
dualize::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Lower (or upper) bounds the entanglement robustness of state ρ with subsystem dimensions dims using level n of the DPS hierarchy (or inner DPS, when inner = true). Argument noise indicates the kind of noise to be used: "white" (default), "separable", or "general". Argument ppt indicates whether to include the partial transposition constraints. Argument dualize determines whether the dual problem is solved instead. WARNING: This is critical for performance, and the correct choice depends on the solver.
Returns the robustness and a witness W (note that for inner = true, this might not be a valid entanglement witness).
Ket.schmidt_number — Function
schmidt_number(
ρ::AbstractMatrix{T},
s::Integer = 2,
dims::AbstractVector = _equal_sizes(ρ),
n::Integer = 1;
ppt::Bool = true,
verbose::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Upper bound on the white noise robustness of ρ such that it has a Schmidt number s.
If a state $ρ$ with local dimensions $d_A$ and $d_B$ has Schmidt number $s$, then there is a PSD matrix $ω$ in the extended space $AA'B'B$, where $A'$ and $B'$ have dimension $s$, such that $ω / s$ is separable against $AA'|B'B$ and $Π^† ω Π = ρ$, where $Π = 1_A ⊗ s ψ^+ ⊗ 1_B$, and $ψ^+$ is a non-normalized maximally entangled state. Separabiity is tested with the DPS hierarchy, with n controlling the how many copies of the $B'B$ subsystem are used.
References:
- Hulpke, Bruss, Lewenstein, Sanpera, arXiv:quant-ph/0401118
- Weilenmann, Dive, Trillo, Aguilar, Navascués, arXiv:1912.10056
Ket.ppt_mixture — Function
function ppt_mixture(
ρ::AbstractMatrix{T},
dims::AbstractVector;
verbose::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Lower bound on the white noise such that ρ is still a genuinely multipartite entangled state and a GME witness that detects ρ.
The set of GME states is approximated by the set of PPT mixtures, so the entanglement across the bipartitions is decided with the PPT criterion. If the state is a PPT mixture, returns a 0 matrix instead of a witness.
Reference: Jungnitsch, Moroder, Gühne, arXiv:quant-ph/0401118
function ppt_mixture(
ρ::AbstractMatrix{T},
dims::AbstractVector,
obs::AbstractVector{<:AbstractMatrix} = Vector{Matrix}();
verbose::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Lower bound on the white noise such that ρ is still a genuinely multipartite entangled state that can be detected with a witness using only the operators provided in obs, and the values of the coefficients defining such a witness.
More precisely, if a list of observables $O_i$ is provided in the parameter obs, the witness will be of the form $∑_i α_i O_i$ and detects ρ only using these observables. For example, using only two-body operators (and lower order) one can call
julia> two_body_basis = collect(Iterators.flatten(n_body_basis(i, 3) for i ∈ 0:2))
julia> ppt_mixture(state_ghz(), [2, 2, 2], two_body_basis)Reference: Jungnitsch, Moroder, Gühne arXiv:quant-ph/0401118
Entropy
Ket.entropy — Function
entropy(ρ::AbstractMatrix{T}, α::real(T) = 1; base = 2)Computes the von Neumann entropy -tr(ρ log ρ) of a positive semidefinite operator ρ using a base base logarithm.
If given α != 1 computes the Rényi entropy log(tr(ρ^α)) / (1 - α).
References:
entropy(p::AbstractVector{T}, α::T = 1; base = 2)Computes the Shannon entropy -Σᵢpᵢlog(pᵢ) of a non-negative vector p using a base base logarithm.
If α != 1 is given computes the Rényi entropy log(Σᵢpᵢ^α )/(1 - α).
References:
Ket.binary_entropy — Function
binary_entropy(p::T, α::T = T(1); base = 2)Computes the Shannon entropy -p log(p) - (1-p)log(1-p) of a probability p using a base base logarithm.
If α != 1 is given computes the Rényi entropy log(p^α + (1-p)^α) / (1-α).
References:
Ket.relative_entropy — Function
relative_entropy(ρ::AbstractMatrix{T}, σ::AbstractMatrix{T}, α::real(T) = 1; base = 2)Computes the (quantum) relative entropy tr(ρ (log ρ - log σ)) between positive semidefinite matrices ρ and σ using a base base logarithm.
If given α != 1 computes the (quantum) Rényi sandwiched relative entropy log(tr((σ^((1-α)/2α) * ρ * σ^((1-α)/2α))^α)) / (α - 1).
Note that the support of ρ must be contained in the support of σ but for efficiency this is not checked.
References:
relative_entropy(p::AbstractVector{T}, q::AbstractVector{T}, α::T = 1; base = 2)Computes the relative entropy Σᵢpᵢlog(pᵢ/qᵢ) between two non-negative vectors p and q using a base base logarithm.
If given α != 1 computes the Rényi relative entropy log(Σᵢpᵢ^α * qᵢ^(1-α)) / (α - 1).
Note that the support of p must be contained in the support of q but for efficiency this is not checked.
References:
Ket.binary_relative_entropy — Function
binary_relative_entropy(p::T, q::T, α::T = 1; base = 2)Computes the binary relative entropy p log(p/q) + (1-p) log((1-p)/(1-q)) between two probabilities p and q using a base base logarithm.
If given α != 1 computes the Rényi binary relative entropy log(p^α * q^(1-α) + (1-p)^α * (1-q)^α) / (α - 1).
References:
Ket.conditional_entropy — Function
conditional_entropy(pAB::AbstractMatrix{T}, α::T = 1; base = 2)Computes the conditional Shannon entropy ∑ᵢⱼpAB[i,j] * log(pAB[i|j]) of the joint probability distribution pAB using a base base logarithm.
If α != 1 is given, computes the conditional Rényi entropy log(∑ⱼpAB[j] * (∑ᵢpAB[i|j]^α)^(1/α)) * α / (1 - α).
References:
- Conditional entropy
- Müller-Lennert et al. arXiv:1306.3142
conditional_entropy(ρ::AbstractMatrix{T}, cond::Union{Integer,AbstractVector{<:Integer}}, dims::AbstractVector, α::real(T) = 1; base = 2)Computes the conditional von Neumann entropy of ρ with subsystem dimensions dims and conditioning systems cond, using a base base logarithm.
If α != 1 is given, computes instead the following lower bound to the conditional Rényi entropy: -Dα(ρ||I ⊗ ρ_cond). It is close to the true value when α is close to 1.
References:
- Conditional quantum entropy
- Müller-Lennert et al. arXiv:1306.3142
Incompatibility
Ket.incompatibility_robustness — Function
incompatibility_robustness(
A::Vector{Measurement{<:Number}};
noise::String = "general",
return_parent::Bool = false,
verbose::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Computes the incompatibility robustness of the measurements in the vector A. Depending on the noise model chosen, the second argument can be "depolarizing" ({tr(Aₐ)I/d}ₐ, where d is the dimension of the system), "random" ({I/n}ₐ, where n is the number of outcomes), "probabilistic" ({pₐI}ₐ, where p is a probability distribution), "jointly_measurable", or "general" (default). Returns the parent POVM if return_parent = true.
References:
- Designolle, Farkas, Kaniewski, arXiv:1906.00448 (for the different noise models)
- Gühne et al., arXiv:2112.06784 (Section III.B.2)
Measurements
Ket.Measurement — Type
Measurement{T}Alias for Vector{Hermitian{T,Matrix{T}}}
Ket.sic_povm — Function
sic_povm([T=ComplexF64,] d::Integer)Constructs a vector of d² vectors |vᵢ⟩ such that |vᵢ⟩⟨vᵢ| forms a SIC-POVM of dimension d. This construction is based on the Weyl-Heisenberg fiducial.
Reference: Appleby, Yadsan-Appleby, Zauner, arXiv:1209.1813
Ket.test_sic — Function
test_sic(vecs)Checks if vecs is a vector of d² vectors |vᵢ⟩ such that |vᵢ⟩⟨vᵢ| forms a SIC-POVM of dimension d.
Ket.test_povm — Function
test_povm(A::Vector{<:AbstractMatrix{T}})Checks if the measurement defined by A is valid (hermitian, semi-definite positive, and normalized).
Ket.dilate_povm — Function
dilate_povm(vecs::Vector{Vector{T}})Does the Naimark dilation of a rank-1 POVM given as a vector of vectors. This is the minimal dilation.
dilate_povm(E::Vector{<:AbstractMatrix})Does the Naimark dilation of a POVM given as a vector of matrices. This always works, but is wasteful if the POVM elements are not full rank.
Ket.povm_dichotomic — Function
povm_dichotomic(E::AbstractMatrix)Creates the dichotomic measurement [E, I - E].
Ket.mub — Function
mub([T=ComplexF64,] d::Integer)Construction of the standard complete set of MUBs. The output contains 1+minᵢ pᵢ^rᵢ bases, where d = ∏ᵢ pᵢ^rᵢ.
Reference: Durt, Englert, Bengtsson, Życzkowski, arXiv:1004.3348
Ket.test_mub — Function
test_mub(B::Vector{Matrix{<:Number}})Checks if the input bases are mutually unbiased.
Ket.discrimination_min_error — Function
discrimination_min_error(
ρ::Vector{<:AbstractMatrix},
q::Vector{<:Real} = fill(1/length(ρ), length(ρ));
verbose = false,
dualize = false,
solver = Hypatia.Optimizer
)Computes the minimum-error probability of discriminating a vector of states ρ with probabilities q, along with the optimal POVM. q is assumed uniform if omitted.
Ket.pretty_good_measurement — Function
pretty_good_measurement(ρ::Vector{<:AbstractMatrix}, q::Vector{<:Real} = ones(length(ρ)))Computes the pretty good measurement POVM for discriminating a vector of states ρ with probabilities q. If q is omitted it is assumed uniform.
Reference: Watrous, Theory of Quantum Information Cp. 3
Nonlocality
Ket.game_chsh — Function
game_chsh([T=Float64,] d::Integer = 2)CHSH-d nonlocal game in probability notation. If T is an integer type the game is unnormalized.
Reference: Buhrman and Massar, arXiv:quant-ph/0409066
Ket.game_cglmp — Function
game_cglmp([T=Float64,] d::Integer = 3)CGLMP nonlocal game in probability notation. If T is an integer type the game is unnormalized.
References:
- Collins, Gisin, Linden, Massar, Popescu, arXiv:quant-ph/0106024 (original game)
- Araújo, Hirsch, Quintino, arXiv:2005.13418 (form presented here)
Ket.game_braunsteincaves — Function
game_braunsteincaves([T=Float64,] s::Integer = 3)Braunstein-Caves nonlocal game in probability notation. Known in the computer science literature as odd cycle game. If T is an integer type the game is unnormalized.
References: Braunstein and Caves doi:10.1016/0003-4916(90)90339-P Cleve et al., arXiv:quant-ph/0404076
Ket.game_inn22 — Function
game_inn22([T=Float64,] n::Integer = 3)inn22 Bell functional in Collins-Gisin notation. Local bound 1.
Reference: Cezary Śliwa, arXiv:quant-ph/0305190
Ket.game_gyni — Function
gyni([T=Float64,] n::Integer)Guess your neighbour's input nonlocal game in probability notation. If T is an integer type the game is unnormalized.
Reference: Almeida et al., arXiv:1003.3844
Ket.game_mermin — Function
game_mermin([T=Float64,] n::Integer)GHZ-Mermin game in probability notation. Local bound 1/2 + 2^-ceil(n/2). If T is an integer type the game is unnormalized.
Reference: Brassard et al., arXiv:quant-ph/0408052
Ket.local_bound — Function
local_bound(G::Array{T,N}; correlation = N < 4, marg = true)Computes the local bound of a multipartite Bell functional G given as an N-dimensional array. If correlation is false, G is assumed to be written in probability notation. If correlation is true, G is assumed to be written in correlation notation, with or without marginals depending on marg.
Reference: Araújo, Hirsch, Quintino, arXiv:2005.13418
Ket.tsirelson_bound — Function
tsirelson_bound(CG::Array, scenario::Tuple, level; verbose::Bool = false, dualize::Bool = false, solver = Hypatia.Optimizer{_solver_type(T)})Upper bounds the Tsirelson bound of a multipartite Bell funcional CG, written in Collins-Gisin notation. scenario is a tuple detailing the number of inputs and outputs, in the order (oa, ob, ..., ia, ib, ...). level is an integer or a string like "1 + A B" determining the level of the NPA hierarchy. verbose determines whether solver output is printed. dualize determines whether the dual problem is solved instead. WARNING: This is critical for performance, and the correct choice depends on the solver.
tsirelson_bound(FC::Array, level; verbose::Bool = false, dualize::Bool = false, solver = Hypatia.Optimizer{_solver_type(T)})Upper bounds the Tsirelson bound of a multipartite Bell funcional FC, written in correlation notation. level is an integer or a string like "1 + A B" determining the level of the NPA hierarchy. verbose determines whether solver output is printed. dualize determines whether the dual problem is solved instead. WARNING: This is critical for performance, and the correct choice depends on the solver.
Ket.seesaw — Function
seesaw(
CG::Matrix,
scenario::Tuple,
d::Integer,
n_trials::Integer = 1;
verbose::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Maximizes a bipartite Bell functional CG in Collins-Gisin notation using the seesaw heuristic. scenario is a vector detailing the number of inputs and outputs, in the order (oa, ob, ia, ib). d is an integer determining the local dimension of the strategy.
Returns a tuple ω, ψ, A, B, where ω is the maximum found, ψ the state, and A,B Alice and Bob's vectors of POVMs.
If oa = ob = 2 the heuristic reduces to a bunch of eigenvalue problems. Otherwise semidefinite programming is needed and we use the assemblage version of seesaw.
The heuristic is executed n_trials times, and the best result is returned.
References:
- Pál and Vértesi, arXiv:1006.3032
- Tavakoli et al., arXiv:2307.02551 (Sec. II.B.1)
Ket.tensor_probability — Function
tensor_probability(CG::Array, scenario::Tuple, behaviour::Bool = false)Takes a multipartite Bell functional CG in Collins-Gisin notation and transforms it to probability notation. scenario is a tuple detailing the number of inputs and outputs, in the order (oa, ob, ..., ia, ib, ...). If behaviour is true do instead the transformation for behaviours. Doesn't assume normalization.
tensor_probability(FC::Matrix, behaviour::Bool = false)Takes a bipartite Bell functional FC in correlation notation and transforms it to probability notation. If behaviour is true do instead the transformation for behaviours. Doesn't assume normalization.
tensor_probability(rho::Hermitian, all_Aax::Vector{Measurement}...)
tensor_probability(rho::Hermitian, Aax::Vector{Measurement}, N::Integer)Applies N sets of measurements onto a state rho to form a probability array. If all parties apply the same measurements, use the shorthand notation.
Ket.tensor_collinsgisin — Function
tensor_collinsgisin(p::Array, behaviour::Bool = false; correlation::Bool = false)Converts a multipartite Bell functional p into Collins-Gisin notation, with marginals in the first index of each dimension. If correlation is true, p is assumed to be written in correlation notation. Otherwise, p is assumed to be written in probability notation. If behaviour is true do instead the transformation for behaviours. Doesn't assume normalization.
Also accepts the arguments of tensor_probability (state and measurements) for convenience.
Ket.tensor_correlation — Function
tensor_correlation(p::AbstractArray, behaviour::Bool = false; collinsgisin::Bool = false, marg::Bool = true)Converts a multipartite Bell functional p into correlation notation, with marginals in the first index of each dimension. If collinsgisin is true, p is assumed to be written in Collins-Gisin notation. Otherwise, p is assumed to be written in probability notation. If marg is false, the output contains only full correlators, with no marginals. If behaviour is true do the transformation for behaviours. Doesn't assume normalization.
Also accepts the arguments of tensor_probability (state and measurements) for convenience.
Ket.nonlocality_robustness — Function
nonlocality_robustness(FP::Array; noise::String = "white", verbose::Bool = false, solver = Hypatia.Optimizer{_solver_type(T)})Computes the nonlocality robustness of the behaviour FP. Argument noise indicates the kind of noise to be used: "white" (default), "local", or "general".
Reference: Baek, Ryu, Lee, arxiv:2311.07077
Norms
Ket.trace_norm — Function
trace_norm(X::AbstractMatrix)Computes trace norm of matrix X.
Ket.kyfan_norm — Function
kyfan_norm(X::AbstractMatrix, k::Integer, p::Real = 2)Computes Ky-Fan (k,p) norm of matrix X.
Ket.schatten_norm — Function
schatten_norm(X::AbstractMatrix, p::Real)Computes Schatten p-norm of matrix X.
Ket.diamond_norm — Function
diamond_norm(
J::AbstractMatrix,
dims::AbstractVector;
verbose::Bool = false,
solver = Hypatia.Optimizer{_solver_type(T)})Computes the diamond norm of the supermap J given in the Choi-Jamiołkowski representation, with subsystem dimensions dims.
Reference: Diamond norm
diamond_norm(K::Vector{<:AbstractMatrix})Computes the diamond norm of the CP map given by the Kraus operators K.
Parameterizations
Ket.parameterized_unitary — Function
parameterized_unitary(λ::AbstractMatrix{T})Produces the unitary matrix parameterized by λ.
Reference: Spengler, Huber, Hiesmayr, arXiv:1004.5252
Random
Ket.random_state — Function
random_state([T=ComplexF64,] d::Integer, k::Integer = d)Produces a uniformly distributed random quantum state in dimension d with rank k.
Reference: Życzkowski and Sommers, arXiv:quant-ph/0012101
Ket.random_state_ket — Function
random_state_ket([T=ComplexF64,] d::Integer)Produces a Haar-random quantum state vector in dimension d.
Reference: Życzkowski and Sommers, arXiv:quant-ph/0012101
Ket.random_unitary — Function
random_unitary([T=ComplexF64,] d::Integer)Produces a Haar-random unitary matrix in dimension d. If T is a real type the output is instead a Haar-random (real) orthogonal matrix.
References: Gilbert W. Stewart, doi:10.1137/0717034 Demmel et al., lawn203
Ket.random_isometry — Function
random_isometry([T=ComplexF64,] d::Integer, k::Integer)Produces a Haar-random isometry with d rows and k columns.
References: Gilbert W. Stewart, doi:10.1137/0717034 Demmel et al., lawn203
Ket.random_povm — Function
random_povm([T=ComplexF64,] d::Integer, n::Integer, k::Integer)Produces a random POVM of dimension d with n outcomes and rank min(k, d).
Reference: Heinosaari et al., arXiv:1902.04751
Ket.random_probability — Function
random_probability([T=Float64,] d::Integer)Produces a random probability vector of dimension d uniformly distributed on the simplex.
Reference: Dirichlet distribution
States
Ket.state_bell_ket — Function
state_bell_ket([T=ComplexF64,] a::Integer, b::Integer, d::Integer = 2)Produces the ket of the generalized Bell state ψ_ab of local dimension d.
Ket.state_bell — Function
state_bell([T=ComplexF64,] a::Integer, b::Integer, d::Integer = 2, v::Real = 1)Produces the generalized Bell state ψ_ab of local dimension d with visibility v.
Ket.state_phiplus_ket — Function
state_phiplus_ket([T=ComplexF64,] d::Integer = 2)Produces the ket of the maximally entangled state ϕ⁺ of local dimension d.
Ket.state_phiplus — Function
state_phiplus([T=ComplexF64,] d::Integer = 2; v::Real = 1)Produces the maximally entangled state ϕ⁺ of local dimension d with visibility v.
Ket.state_psiminus_ket — Function
state_psiminus_ket([T=ComplexF64,] d::Integer = 2)Produces the ket of the maximally entangled state ψ⁻ of local dimension d.
Ket.state_psiminus — Function
state_psiminus([T=ComplexF64,] d::Integer = 2; v::Real = 1)Produces the maximally entangled state ψ⁻ of local dimension d with visibility v.
Ket.state_supersinglet_ket — Function
state_supersinglet_ket([T=ComplexF64,] N::Integer = 3; coeff = 1/√N!)Produces the ket of the N-partite N-level singlet state.
Reference: Adán Cabello, arXiv:quant-ph/0203119
Ket.state_supersinglet — Function
state_supersinglet([T=ComplexF64,] N::Integer = 3; v::Real = 1)Produces the N-partite N-level singlet state with visibility v. This state is invariant under simultaneous rotations on all parties: $(U ⊗ ... ⊗ U) ρ (U ⊗ ... ⊗ U)' = ρ$.
Reference: Adán Cabello, arXiv:quant-ph/0203119
Ket.state_ghz_ket — Function
state_ghz_ket([T=ComplexF64,] N::Integer = 3, d::Integer = 2; coeff = 1/√d)Produces the ket of the GHZ state with N parties and local dimension d.
Ket.state_ghz — Function
state_ghz([T=ComplexF64,] N::Integer = 3, d::Integer = 2; v::Real = 1, coeff = 1/√d)Produces the GHZ state with N parties, local dimension d, and visibility v.
Ket.state_w_ket — Function
state_w_ket([T=ComplexF64,] N::Integer = 3; coeff = 1/√N)Produces the ket of the N-partite W state.
Ket.state_w — Function
state_w([T=ComplexF64,] N::Integer = 3; v::Real = 1, coeff = 1/√N)Produces the N-partite W state with visibility v.
Ket.state_dicke_ket — Function
state_dicke_ket([T=ComplexF64,] N::Integer, k::Integer; coeff = 1/√Cᴺₖ)Produces the ket of the N-partite Dicke state with k excitations.
Reference: Robert H. Dicke doi:10.1103/PhysRev.93.99
Ket.state_dicke — Function
state_dicke([T=ComplexF64,] N::Integer, k::Integer; v::Real = 1)Produces the N-partite Dicke state with k excitations.
Reference: Robert H. Dicke doi:10.1103/PhysRev.93.99
Ket.state_horodecki33 — Function
state_horodecki33([T=ComplexF64,] a::Real)Produces the 3 × 3 bipartite PPT-entangled Horodecki state with parameter a.
Reference: Paweł Horodecki, arXiv:quant-ph/9703004
Ket.state_horodecki24 — Function
state_horodecki24([T=ComplexF64,] b::Real)Produces the 2 × 4 bipartite PPT-entangled Horodecki state with parameter b.
Reference: Paweł Horodecki, arXiv:quant-ph/9703004
Ket.state_grid — Function
state_grid([T=ComplexF64], dA::Integer, dB::Integer, edges::Vector{Vector{ntuple{2, Int}}}; weights::Vector{T} = ones(T, length(edges)))Produces the bipartite dA × dB grid state according to the dA × dB 2D (hyper-)graph with edges and weights.
Reference:
- Lockhart et al., arXiv:1705.09261
- Ghimire et al., arXiv:2207.09826
Ket.state_crosshatch — Function
state_crosshatch([T=ComplexF64])Produces a bound entangled bipartite 3 × 3 crosshatch state.
Reference: Lockhart et al., arXiv:1705.09261
Ket.state_sindici_piani_ket — Function
state_sindici_piani_ket([T=ComplexF64], d::Integer, k::Integer = 1, l::Integer = d; coeff = inv(_sqrt(T, 2)))Produces the ket of Sindici-Piani state of even local dimensions d × d
Reference: Sindici and Piani, arXiv:1708.06595
Ket.state_sindici_piani — Function
state_sindici_piani([T=ComplexF64], d::Integer; coeffs = [√2/√d, ⋯, √2/√d])Produces the Sindici-Piani state of even local dimensions d × d with visibility v.
Reference: Sindici and Piani, arXiv:1708.06595
Ket.white_noise — Function
white_noise(ρ::AbstractMatrix, v::Real)Returns v * ρ + (1 - v) * id, where id is the maximally mixed state.
Ket.white_noise! — Function
white_noise!(ρ::AbstractMatrix, v::Real)Modifies ρ in place to tranform it into v * rho + (1 - v) * id where id is the maximally mixed state.
Internal functions
Ket._dps_constraints! — Function
_dps_constraints!(model::JuMP.GenericModel, ρ::AbstractMatrix, dims::AbstractVector, n::Integer; ppt::Bool = true, is_complex::Bool = true, isometry::AbstractMatrix = I(size(ρ, 1)))Constrains state ρ of dimensions dims in JuMP model model to respect the DPS constraints of level n. Dimensions are specified in dims = [dA, dB] and the extensions will be done on the second subsystem. The extensions can be symmetric real matrices (is_complex = false) or Hermitian PSD. With ppt = true, PPT constraints are enforced for transposed subsystems 2:i, for i ∈ 2:n+1. Use isometry to specify a $V$ to be applied in the constraint $ρ = V' * tr_{B_2 ... B_n}(Ξ) V$.
Reference: Doherty, Parrilo, Spedalieri, arXiv:quant-ph/0308032
Ket._inner_dps_constraints! — Function
_inner_dps_constraints!(model::JuMP.GenericModel, ρ::AbstractMatrix, dims::AbstractVector, n::Integer; ppt::Bool = true, is_complex::Bool = true, isometry::AbstractMatrix = I(size(ρ, 1)))Constrains state ρ of dimensions dims in JuMP model model to respect the Inner DPS constraints of level n. Dimensions are specified in dims = [dA, dB] and the extensions will be done on the second subsystem. The extensions can be symmetric real matrices (is_complex = false) or Hermitian PSD. With ppt = true, the extended part is constrained to be PPT for the [1:⌈n/2⌉+1, rest] partition.
References: Navascués, Owari, Plenio arXiv:0906.2735 and arXiv:0906.2731
Ket._partition — Function
partition(n::Integer, k::Integer)If n ≥ k partitions the set 1:n into k parts as equally sized as possible. Otherwise partitions it into n parts of size 1.
Ket._fiducial_WH — Function
_fiducial_WH([T=ComplexF64,] d::Integer)Computes the fiducial Weyl-Heisenberg vector of dimension d.
References:
- Appleby, Yadsan-Appleby, Zauner, arXiv:1209.1813
- www.gerhardzauner.at/sicfiducials.html