Bases: object
FIXME: need to write documentation.
>>> from qitensor import qubit, qudit, Superoperator, CP_Map
>>> ha = qudit('a', 3)
>>> hb = qubit('b')
>>> rho = (ha*hb).random_density()
>>> ET = Superoperator.from_function(ha, lambda x: x.T)
>>> ET
Superoperator( |a><a| to |a><a| )
>>> (ET(rho) - rho.transpose(ha)).norm() < 1e-14
True
>>> Superoperator.from_function(ha, lambda x: x.H)
Traceback (most recent call last):
...
ValueError: function was not linear
>>> from qitensor import qubit, qudit, Superoperator
>>> ha = qudit('a', 3)
>>> hb = qubit('b')
>>> rho = (ha*hb).random_density()
>>> T = Superoperator.transposer(ha)
>>> T
Superoperator( |a><a| to |a><a| )
>>> (T(rho) - rho.transpose(ha)).norm() < 1e-14
True
Bases: qitensor.superop.Superoperator
FIXME: need to write documentation.
The complimentary channel.
The channel isometry.
Adds two CP maps. The returned map has the same action as E1+E2, but the environment is the direct sum of the component environments.
>>> import numpy.linalg as linalg
>>> from qitensor import qudit, CP_Map
>>> ha = qudit('a', 2)
>>> hb = qudit('b', 3)
>>> E1 = CP_Map.random(ha, hb, 'hc1')
>>> E2 = CP_Map.random(ha, hb, 'hc2')
>>> X = E1 + E2
>>> Y = E1.add2(E2)
>>> linalg.norm(X.as_matrix() - Y.as_matrix()) < 1e-14
True
>>> (E1.env_space, E2.env_space, Y.env_space)
(|hc1>, |hc2>, |hc1+hc2>)
Compute S(B)-S(C) after passing the given state through the channel.
>>> from qitensor import qudit, CP_Map
>>> ha = qudit('a', 5)
>>> rho = ha.random_density()
>>> E = CP_Map.decohere(ha)
>>> (E(rho) - ha.diag(rho.diag(as_np=True))).norm() < 1e-14
True
Create a channel that has probability p of erasing the input, and 1-p of perfectly transmitting the input. The output space has dimension one greater than the input space, and the receiver is notified of erasure via the extra computational basis state. If p=0.5 then the channel is symmetric.
>>> from qitensor import qubit, qudit, CP_Map
>>> ha = qudit('a', 3)
>>> hb = qubit('b')
>>> rho = (ha*hb).random_density()
>>> CP_Map.from_function(ha, lambda x: x.T)
Traceback (most recent call last):
...
ValueError: matrix didn't correspond to a completely positive superoperator (min eig=-1.0)
>>> U = ha.random_unitary()
>>> EU = CP_Map.from_function(ha, lambda x: U*x*U.H)
>>> EU
CP_Map( |a><a| to |a><a| )
>>> (EU(rho) - U*rho*U.H).norm() < 1e-14
True
>>> from qitensor import qudit, CP_Map
>>> ha = qudit('a', 2)
>>> hb = qudit('b', 3)
>>> hx = qudit('x', 5)
>>> E1 = CP_Map.random(ha*hb, hx)
>>> E2 = CP_Map.random(hx, ha*hb)
>>> m = E2.as_matrix() * E1.as_matrix()
>>> E3 = CP_Map.from_matrix(m, ha*hb, ha*hb)
>>> rho = (ha*hb).random_density()
>>> (E2(E1(rho)) - E3(rho)).norm() < 1e-14
True
>>> from qitensor import qubit, CP_Map
>>> ha = qubit('a')
>>> hb = qubit('b')
>>> rho = (ha*hb).random_density()
>>> E = CP_Map.identity(ha)
>>> (E(rho) - rho).norm() < 1e-14
True
Returns the channel ket.
>>> from qitensor import qudit, CP_Map
>>> ha = qudit('a', 2)
>>> hb = qudit('b', 2)
>>> E = CP_Map.random(ha, hb, 'c')
>>> E.J.space
|b,c><a|
>>> E.ket().space
|a,b,c>
>>> F = CP_Map.random(ha, ha, 'c')
>>> F.ket()
Traceback (most recent call last):
...
HilbertError: 'channel ket can only be made if input space is different from output and environment spaces'
>>> from qitensor import qudit, CP_Map
>>> ha = qudit('a', 5)
>>> rho = ha.random_density()
>>> E = CP_Map.noisy(ha, 0.2)
>>> (E(rho) - 0.8*rho - 0.2*ha.fully_mixed()).norm() < 1e-14
True
Compute I(X;B) - I(X;C) where X is a classical ancillary system that records which state of the ensemble was passed through the channel.
>>> from qitensor import qudit, CP_Map
>>> ha = qudit('a', 5)
>>> rho = ha.random_density()
>>> E = CP_Map.totally_noisy(ha)
>>> (E(rho) - ha.fully_mixed()).norm() < 1e-14
True
>>> from qitensor import qubit, CP_Map
>>> ha = qubit('a')
>>> hb = qubit('b')
>>> U = ha.random_unitary()
>>> rho = (ha*hb).random_density()
>>> E = CP_Map.unitary(U)
>>> (E(rho) - U*rho*U.H).norm() < 1e-14
True