In QIT, quantum states are represented by the state class, defined in this module.
check() | Checks the validity of the state. |
subsystems() | Number of subsystems in the state. |
dims() | Dimensions of the state. |
clean_selection(sys) | Make a subsystem set unique and sorted, return it as an array. |
invert_selection(sys) | Invert and sort a subsystem set. |
fix_phase([inplace]) | Apply a global phase convention to a ket state. |
normalize([inplace]) | Normalize the state to unity. |
to_ket([inplace]) | Convert the state representation into a ket (if possible). |
to_op([inplace]) | Convert state representation into a state operator. |
trace() | Trace of the state operator. |
ptrace(sys[, inplace]) | Partial trace. |
ptranspose(sys[, inplace]) | Partial transpose. |
reorder(perm[, inplace]) | Change the relative order of subsystems in a state. |
tensor(*arg) | Tensor product of states. |
plot([symbols]) | State tomography plot. |
ev(A) | Expectation value of an observable in the state. |
var(A) | Variance of an observable in the state. |
prob() | Measurement probabilities of the state in the computational basis. |
projector() | Projection operator defined by the state. |
u_propagate(U) | Propagate the state using a unitary. |
propagate(G, t[, out_func]) | Propagate the state continuously in time. |
kraus_propagate(E) | Apply a quantum operation to the state. |
measure([M, do]) | Quantum measurement. |
fidelity(r) | Fidelity of two states. |
trace_dist(r) | Trace distance of two states. |
purity() | Purity of the state. |
schmidt([sys, full]) | Schmidt decomposition. |
entropy([sys, alpha]) | Von Neumann or Renyi entropy of the state. |
concurrence([sys]) | Concurrence of the state. |
negativity(sys) | Negativity of the state. |
lognegativity(sys) | Logarithmic negativity of the state. |
scott(m) | Scott’s average bipartite entanglement measure. |
locc_convertible(t, sys) | LOCC convertibility of states. |
bloch_vector() | Generalized Bloch vector. |
bloch_state(A[, dim]) | State corresponding to a generalized Bloch vector. |
True if s and t have equal dimensions.
Index multipliers for C-ordered data
Class for quantum states.
Describes the state (pure or mixed) of a discrete, possibly composite quantum system. The subsystem dimensions can be obtained with dims (big-endian ordering).
State class instances are special cases of lmaps. They have exactly two indices. If self.dim[1] == (1,), it is a ket representing a pure state. Otherwise both indices must have equal dimensions and the object represents a state operator.
Does not require the state to be physical (it does not have to be trace-1, Hermitian, or nonnegative).
State corresponding to a generalized Bloch vector. s = bloch_state(A) assume s = bloch_state(A, dim) give state dimensions explicitly
Returns the state s corresponding to the generalized Bloch vector A.
A is defined in terms of the standard Hermitian tensor basis B corresponding to the dimension vector dim. If dim is not given, it is assumed to be sqrt(A.shape).
where D = prod(dim). For valid states norm(A, 2) <= sqrt(D).
Generalized Bloch vector.
Returns the generalized Bloch vector A corresponding to the state.
For an n-subsystem state the generalized Bloch vector is an order-n correlation tensor defined in terms of the standard Hermitian tensor basis B corresponding to state dimensions:
where D = prod(self.dims()). A is always real since is Hermitian. For valid, normalized states
self.purity() <= 1 implies norm(A, ‘fro’) <= sqrt(D)
self.trace() = 1 implies A[0, 0, ..., 0] == 1
E.g. for a single-qubit system norm(A, ‘fro’) <= sqrt(2).
Checks the validity of the state.
Makes sure it is normalized, and if an operator, Hermitian and semipositive.
Make a subsystem set unique and sorted, return it as an array. TODO valid too?
Concurrence of the state.
Returns the concurrence of the state s wrt. the partitioning given by the listing of subsystems in the vector sys.
Dimensions of the state.
Von Neumann or Renyi entropy of the state.
Returns the Renyi entropy of order , .
When , this coincides with the von Neumann entropy .
If sys == None, returns the entropy of the state. If sys is a vector of subsystem indices, returns the entropy of entanglement of the state wrt. the partitioning defined by sys. Entropy of entanglement is only defined for pure states.
Expectation value of an observable in the state.
Returns the expectation value of the observable A in the state. A has to be Hermitian.
Fidelity of two states.
Fidelity of two state operators rho and sigma is defined as . For state vectors this is equivalent to the overlap, .
Fidelity is symmetric in its arguments and bounded in the interval [0,1]. See [17], chapter 9.2.2.
Apply a global phase convention to a ket state.
Returns a copy of the state. Additionally, if the state is represented with a ket, the copy has a global phase such that the first nonzero element in the state vector is real and positive.
Invert and sort a subsystem set.
Apply a quantum operation to the state.
Applies the quantum operation E to the state. is a set of Kraus operators.
LOCC convertibility of states.
For bipartite pure states s and t, returns True if s can be converted to t using local operations and classical communication (LOCC). sys is a vector of subsystems defining the partition.
See [17], chapter 12.5.1
Logarithmic negativity of the state.
Returns the logarithmic negativity of the state wrt. the partitioning given by the listing of subsystems in the vector sys.
Quantum measurement.
(p, res, c)
= measure() measure the entire system projectively
= measure((1, 4)) measure subsystems 1 and 4 projectively
= measure([M_1, M_2, ...]) perform a general measurement
= measure(A) measure a Hermitian observable A
Performs a quantum measurement on the state.
p = measure(..., do=’P’) returns the vector p, where p[k] is the probability of obtaining result k in the measurement. For a projective measurement in the computational basis this corresponds to the ket .
(p, res) = measure(...) additionally returns the index of the result of the measurement, res, chosen at random from the probability distribution p.
(p, res, c) = measure(..., do=’C’) additionally gives c, the collapsed state corresponding to the measurement result res.
Negativity of the state.
Returns the negativity of the state wrt. the partitioning given by the listing of subsystems in the vector sys.
Normalize the state to unity.
State tomography plot.
Plots the probabilities of finding a system in this state in the different computational basis states upon measurement. Relative phases are represented by the colors of the bars.
If the state is nonpure, also plots the coherences.
Measurement probabilities of the state in the computational basis.
Returns a vector of probabilities of finding a system in each of the different states of the computational basis.
Projection operator defined by the state.
Returns the projection operator P defined by the state.
Propagate the state continuously in time.
propagate(H, t) Hamiltonian
propagate(L, t) Liouvillian
propagate([H, A_1, A_2, ...], t) Hamiltonian and Lindblad ops
Propagates the state using the generator G for the time t, returns the resulting state.
The generator G can either be a
For time-dependent cases, G can be a function G(t) which takes a time instance t as input and returns the corresponding generator(s).
If t is a vector of increasing time instances, returns a list containing the propagated state for each time given in t.
Optional parameters: out_func: If given, for each time instance t returns out_func(s(t), G(t)). Any unrecognized keyword args are passed on to the ODE solver.
Partial trace.
Returns the partial trace of the state over the subsystems listed in the vector sys.
Partial transpose.
Returns the partial transpose of the state wrt. the subsystems listed in the vector sys.
Purity of the state.
Returns the purity of a normalized state, . Equivalent to linear entropy, .
Change the relative order of subsystems in a state.
reorder([2, 1, 0]) reverse the order of three subsystems
reorder([2, 5]) swap subsystems 2 and 5
Reorders the subsystems of the state according to the permutation perm.
The permutation vector may consist of either exactly two subsystem indices (to be swapped), or a full permutation of subsystem indices.
Schmidt decomposition.
lambda = schmidt(sys)
lambda, u, v = schmidt(sys, full=True)
Calculates the Schmidt decomposition of the (pure) state. Subsystems listed in vector sys constitute part A, the rest forming part B. Vector lambda will contain the Schmidt coefficients.
If required, matrices u and v will contain the corresponding orthonormal Schmidt bases for A and B, respectively, as column vectors, i.e.
The state is then given by .
See [17], chapter 2.5.
Scott’s average bipartite entanglement measure.
Returns the vector Q containing the terms of the Scott entanglement measure of the system for partition size m.
When m = 1 this is coincides with the Meyer-Wallach entanglement measure.
Number of subsystems in the state.
Tensor product of states.
Returns the tensor product state of states s1, s2, ...
Convert the state representation into a ket (if possible).
If the state is pure returns q, a copy of the state, for which the internal representation (q.data) is guaranteed to be a ket vector.
Convert state representation into a state operator.
Returns q, a copy of the state for which the internal representation (q.data) is guaranteed to be a state operator.
Trace of the state operator.
Returns the trace of the state operator of quantum state s. For a pure state this is equal to the squared norm of the state vector.
Trace distance of two states.
Trace distance between state operators r and s is defined as , where A = r-s.
Equivalently , where are the eigenvalues of A (since A is Hermitian). See [17], chapter 9.2.1.
Propagate the state using a unitary.
Propagates the state using the unitary propagator U, returns the resulting state.
Variance of an observable in the state.
Returns the variance of the observable A in the state. A has to be Hermitian.
Wrapper for state.fidelity.
Wrapper for state.trace_dist.