Skip to content

Commit 7affd79

Browse files
committed
Add ChiBasis and some othe work on superoperator bases
1 parent fc5ee84 commit 7affd79

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

src/bases.jl

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,16 @@ basis_l(b::KetBraBasis) = b.left
432432
basis_r(b::KetBraBasis) = b.right
433433
Base.:(==)(b1::KetBraBasis, b2::KetBraBasis) = (b1.left == b2.left && b1.right == b2.right)
434434
dimension(b::KetBraBasis) = dimension(b.left)*dimension(b.right)
435+
tensor(b1::KetBraBasis, b2::KetBraBasis) = KetBraBasis(tensor(b1.left,b2.left), tensor(b1.right, b2.right))
435436

437+
"""
438+
ChoiBasis(ref_basis,out_basis)
439+
440+
The Choi basis is used to represent superoperators in the Choi representation
441+
where the `ref_basis` denotes the ancillary reference system with which an input
442+
state will be jointly measured in order to accomplish teleportation simulation
443+
of the channel with the channel's output appearing in the `out_basis` system.
444+
"""
436445
struct ChoiBasis{BL<:Basis, BR<:Basis} <: Basis
437446
ref::BL
438447
out::BR
@@ -441,7 +450,13 @@ basis_l(b::ChoiBasis) = b.ref
441450
basis_r(b::ChoiBasis) = b.out
442451
Base.:(==)(b1::ChoiBasis, b2::ChoiBasis) = (b1.ref == b2.ref && b1.out == b2.out)
443452
dimension(b::ChoiBasis) = dimension(b.ref)*dimension(b.out)
453+
tensor(b1::ChoiBasis, b2::ChoiBasis) = ChoiBasis(tensor(b1.ref,b2.ref), tensor(b1.out, b2.out))
444454

455+
function _check_is_spinhalfbasis(b)
456+
for i=1:length(b)
457+
(b[i] isa SpinBasis && dimension(b[i]) == 2) || throw(ArgumentError("Must have only SpinBasis(1//2) to be compatible with pauli representation"))
458+
end
459+
end
445460
"""
446461
PauliBasis(N)
447462
@@ -452,11 +467,43 @@ The dimension of the basis is 2²ᴺ.
452467
struct PauliBasis{T<:Integer} <: Basis
453468
N::T
454469
end
470+
function PauliBasis(bl::Basis, br::Basis)
471+
bl == br || throw(ArgumentError("Both bases must be equal"))
472+
_check_is_spinhalfbasis(bl)
473+
PauliBasis(length(bl))
474+
end
475+
basis_l(b::PauliBasis) = SpinBasis(1//2)^b.N
476+
basis_r(b::PauliBasis) = SpinBasis(1//2)^b.N
455477
Base.:(==)(b1::PauliBasis, b2::PauliBasis) = b1.N == b2.N
456-
shape(b::PauliBasis) = fill(4, b.N)
457478
dimension(b::PauliBasis) = 4^b.N
458-
Base.length(b::PauliBasis) = b.N
459-
Base.getindex(b::PauliBasis, i) = PauliBasis(length(i))
479+
tensor(b1::PauliBasis, b2::PauliBasis) = PauliBasis(b1.N+b2.N)
480+
481+
"""
482+
ChiBasis(N)
483+
484+
The basis for a Chi process matrix, which is just the Choi state in the Pauli
485+
operator basis. However we do not use the `ChoiBasis`, partly to have easier
486+
dispatch on types, and partly because there's no sensible way to distingish
487+
between the "reference" and "output" systems as that information is lost in the
488+
computational to Pauli basis transformation (i.e. two indices into one).
489+
490+
TODO explain better why dimension base is 2, see sec III.E.
491+
"""
492+
struct ChiBasis{T<:Integer} <: Basis
493+
Nl::T
494+
Nr::T
495+
end
496+
ChiBasis(N) = ChiBasis(N,N)
497+
function ChiBasis(bl::Basis, br::Basis)
498+
_check_is_spinhalfbasis(bl)
499+
_check_is_spinhalfbasis(br)
500+
ChiBasis(length(bl), length(br))
501+
end
502+
basis_l(b::ChiBasis) = SpinBasis(1//2)^b.Nl
503+
basis_r(b::ChiBasis) = SpinBasis(1//2)^b.Nr
504+
Base.:(==)(b1::ChiBasis, b2::ChiBasis) = (b1.Nl == b2.Nl && b1.Nr == b2.Nr)
505+
dimension(b::ChiBasis) = 2^(b.Nl+b.Nr)
506+
tensor(b1::ChiBasis, b2::ChiBasis) = ChiBasis(b1.Nl+b2.Nl, b1.Nr+b2.Nr)
460507

461508
"""
462509
HWPauliBasis(N)

0 commit comments

Comments
 (0)