import qutip
from qutip.qinstrument import (
QInstrument,
basis_measurement,
pauli_measurement
)
H = qutip.operations.hadamard_transform()
ket_plus = H * qutip.basis(2, 0)
z_instrument = basis_measurement(2)
z_instrument
QInstrument id=23190ff7e80 { dims [[[2], [2]], [[2], [2]]] outcomes Seq(0,) Seq(1,) }
z_instrument.sample(ket_plus)
(Seq(0,), Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', isherm=True Qobj data = [[1. 0.] [0. 0.]])
(H * z_instrument)(ket_plus)
{Seq(0,): Outcome(probability=0.5000000000000002, output_state=Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', isherm=True Qobj data = [[0.5 0.5] [0.5 0.5]]), Seq(1,): Outcome(probability=0.5000000000000002, output_state=Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', isherm=True Qobj data = [[ 0.5 -0.5] [-0.5 0.5]])}
z_instrument * z_instrument
QInstrument id=23190ff9d00 { dims [[[2], [2]], [[2], [2]]] outcomes Seq(0, 0) Seq(1, 1) }
qutip.tensor([z_instrument] * 2)
QInstrument id=23190ff9460 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(Par(0, 0),) Seq(Par(0, 1),) Seq(Par(1, 0),) Seq(Par(1, 1),) }
qutip.tensor(z_instrument.with_finite_visibility(0.95) ** 2, z_instrument)
QInstrument id=23190ff3880 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(Par(Seq(0, 0), 0),) Seq(Par(Seq(0, 0), 1),) Seq(Par(Seq(1, 0), 0),) Seq(Par(Seq(1, 0), 1),) Seq(Par(Seq(0, 1), 0),) Seq(Par(Seq(0, 1), 1),) Seq(Par(Seq(1, 1), 0),) Seq(Par(Seq(1, 1), 1),) }
z_instrument * z_instrument
QInstrument id=23190ff3d90 { dims [[[2], [2]], [[2], [2]]] outcomes Seq(0, 0) Seq(1, 1) }
z_instrument.with_finite_visibility(0.95) ** 2
QInstrument id=23190fc7550 { dims [[[2], [2]], [[2], [2]]] outcomes Seq(0, 0) Seq(1, 0) Seq(0, 1) Seq(1, 1) }
basis_measurement(3)
QInstrument id=23190fc79d0 { dims [[[3], [3]], [[3], [3]]] outcomes Seq(0,) Seq(1,) Seq(2,) }
qutip.QInstrument(qutip.projection(4, 0, 0)).complete()
QInstrument id=23190fc7b50 { dims [[[4], [4]], [[4], [4]]] outcomes Seq() Seq('⊥',) }
qutip.QInstrument(qutip.projection(4, 0, 0)).complete().reindex()
QInstrument id=23190fc7eb0 { dims [[[4], [4]], [[4], [4]]] outcomes Seq(0,) Seq(1,) }
pauli_measurement("ZZ") * pauli_measurement("XX")
QInstrument id=23190fbc9d0 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(+XX, +ZZ) Seq(-XX, +ZZ) Seq(+XX, -ZZ) Seq(-XX, -ZZ) }
(pauli_measurement("ZZ") * pauli_measurement("XX")) ** 2
QInstrument id=23190fbccd0 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(+XX, +ZZ, +XX, +ZZ) Seq(-XX, +ZZ, -XX, +ZZ) Seq(+XX, -ZZ, +XX, -ZZ) Seq(-XX, -ZZ, -XX, -ZZ) }
(
pauli_measurement("ZZ") * pauli_measurement("XX")
).with_finite_visibility(0.95) ** 2
QInstrument id=23190fb1ac0 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(+XX, +ZZ, +XX, +ZZ) Seq(-XX, +ZZ, +XX, +ZZ) Seq(+XX, -ZZ, +XX, +ZZ) Seq(-XX, -ZZ, +XX, +ZZ) Seq(+XX, +ZZ, -XX, +ZZ) Seq(-XX, +ZZ, -XX, +ZZ) Seq(+XX, -ZZ, -XX, +ZZ) Seq(-XX, -ZZ, -XX, +ZZ) Seq(+XX, +ZZ, +XX, -ZZ) Seq(-XX, +ZZ, +XX, -ZZ) Seq(+XX, -ZZ, +XX, -ZZ) Seq(-XX, -ZZ, +XX, -ZZ) Seq(+XX, +ZZ, -XX, -ZZ) Seq(-XX, +ZZ, -XX, -ZZ) Seq(+XX, -ZZ, -XX, -ZZ) Seq(-XX, -ZZ, -XX, -ZZ) }
When using custom output labels, you can specify sequences of outcomes with ,
and parallel outcomes with ;
. Integers in strings are automatically converted, but other strings are preserved.
QInstrument({
'0, 1, 2; 4, ⊥': qutip.projection(4, 0, 0)
})
QInstrument id=23190fb1f70 { dims [[[4], [4]], [[4], [4]]] outcomes Seq(Par(Seq(0, 1, 2), Seq(4, '⊥')),) }
For more complicated labels, Seq
and Par
can also be used directly. For example, the string '0, 1, 2; 4, ⊥'
can also be written more explicitly as Seq(Par(Seq(0, 1, 2), Seq(4, '⊥')),)
.
from qutip.qinstrument import Seq, Par
QInstrument({
Seq(Par(Seq(0, 1, 2), Seq(4, '⊥')),): qutip.projection(4, 0, 0),
Seq(Par(Seq(0, 1, 2), Seq(Par('A', 'B'), 'C')),): qutip.projection(4, 1, 1)
})
QInstrument id=2319106e490 { dims [[[4], [4]], [[4], [4]]] outcomes Seq(Par(Seq(0, 1, 2), Seq(4, '⊥')),) Seq(Par(Seq(0, 1, 2), Seq(Par('A', 'B'), 'C')),) }
ins = (
pauli_measurement("ZZ") * pauli_measurement("XX")
).with_finite_visibility(0.95) ** 2
ins.nonselective_process
ins.iscptp
True
ins.ishp
True
ins.istp
True
ins.iscp
True
z_instrument & z_instrument.with_finite_visibility(0.95)
QInstrument id=2319108d730 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(Par(0, 0),) Seq(Par(0, 1),) Seq(Par(1, 0),) Seq(Par(1, 1),) }
z_instrument ^ 3
QInstrument id=23190fc7df0 { dims [[[2, 2, 2], [2, 2, 2]], [[2, 2, 2], [2, 2, 2]]] outcomes Seq(Par(0, 0, 0),) Seq(Par(0, 0, 1),) Seq(Par(0, 1, 0),) Seq(Par(0, 1, 1),) Seq(Par(1, 0, 0),) Seq(Par(1, 0, 1),) Seq(Par(1, 1, 0),) Seq(Par(1, 1, 1),) }
reset = z_instrument.if_({
1: qutip.to_super(qutip.sigmax())
})
reset
QInstrument id=2319108d4c0 { dims [[[2], [2]], [[2], [2]]] outcomes Seq(0,) Seq(1,) }
reset.nonselective_process
z_instrument.if_({
1: qutip.QInstrument(qutip.to_super(qutip.sigmax()))
})
QInstrument id=2319108d490 { dims [[[2], [2]], [[2], [2]]] outcomes Seq(0,) Seq(1,) }
V = (
(qutip.qeye(2) & qutip.qip.operations.cnot()) *
(qutip.qeye(2) & qutip.qip.operations.hadamard_transform() & qutip.qeye(2)) *
(qutip.qeye(2) & qutip.basis(2, 0) & qutip.basis(2, 0))
)
prepare_bell = qutip.sprepost(V, V.dag())
prepare_bell
prepare_bell(qutip.basis(2, 0)).ptrace([0])
prepare_bell(qutip.basis(2, 0)).ptrace([1, 2])
bell_measurement = pauli_measurement("ZZ") * pauli_measurement("XX")
bell_measurement
QInstrument id=2319108d6a0 { dims [[[2, 2], [2, 2]], [[2, 2], [2, 2]]] outcomes Seq(+XX, +ZZ) Seq(-XX, +ZZ) Seq(+XX, -ZZ) Seq(-XX, -ZZ) }
teleport_wo_correction = (
(bell_measurement & qutip.to_super(qutip.qeye(2))) *
prepare_bell
)
teleport_wo_correction
QInstrument id=231910999d0 { dims [[[2, 2, 2], [2, 2, 2]], [[2], [2]]] outcomes Seq(+XX, +ZZ) Seq(-XX, +ZZ) Seq(+XX, -ZZ) Seq(-XX, -ZZ) }
teleport = teleport_wo_correction.if_({
qutip.Seq("XX", "ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.qeye(2)),
qutip.Seq("-XX", "ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.sigmaz()),
qutip.Seq("XX", "-ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.sigmax()),
qutip.Seq("-XX", "-ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.sigmay()),
})
teleport.nonselective_process(qutip.basis(2, 0)).ptrace([2])
teleport.nonselective_process(qutip.basis(2, 1)).ptrace([2])
teleport.nonselective_process(qutip.qip.operations.hadamard_transform() * qutip.basis(2, 0)).ptrace([2])
teleport_wo_correction = (
(bell_measurement.with_finite_visibility(0.95) & qutip.to_super(qutip.qeye(2))) *
prepare_bell
)
teleport = teleport_wo_correction.if_({
qutip.Seq("XX", "ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.qeye(2)),
qutip.Seq("-XX", "ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.sigmaz()),
qutip.Seq("XX", "-ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.sigmax()),
qutip.Seq("-XX", "-ZZ"): qutip.to_super((qutip.qeye(2) ^ 2) & qutip.sigmay()),
})
teleport.nonselective_process(qutip.qip.operations.hadamard_transform() * qutip.basis(2, 0)).ptrace([2])