Table Of Contents

Previous topic

Linear maps (qit.lmap)

Next topic

Quantum gates (qit.gate)

This Page

Quantum states (qit.state)

In QIT, quantum states are represented by the state class, defined in this module.

Utilities

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.

Physics

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.

Quantum information

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.

Other state representations

bloch_vector() Generalized Bloch vector.
bloch_state(A[, dim]) State corresponding to a generalized Bloch vector.
qit.state.equal_dims(s, t)

True if s and t have equal dimensions.

qit.state.index_muls(dim)

Index multipliers for C-ordered data

class qit.state.state(s, dim=None)

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).

static bloch_state(A, dim=None)

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).

\rho_s = \sum_{ijk\ldots} A_{ijk\ldots} B_{ijk\ldots} / \sqrt{D},

where D = prod(dim). For valid states norm(A, 2) <= sqrt(D).

bloch_vector()

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:

A_{ijk\ldots} = \sqrt{D} \mathrm{Tr}(\rho_s  B_{ijk\ldots}),

where D = prod(self.dims()). A is always real since \rho_s 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).

check()

Checks the validity of the state.

Makes sure it is normalized, and if an operator, Hermitian and semipositive.

clean_selection(sys)

Make a subsystem set unique and sorted, return it as an array. TODO valid too?

concurrence(sys=None)

Concurrence of the state.

Returns the concurrence of the state s wrt. the partitioning given by the listing of subsystems in the vector sys.

See [23], [11].

dims()

Dimensions of the state.

entropy(sys=None, alpha=1)

Von Neumann or Renyi entropy of the state.

Returns the Renyi entropy of order \alpha, S_\alpha(\rho) = \frac{1}{1-\alpha} \log_2 \mathrm{Tr}(\rho^\alpha).

When \alpha = 1, this coincides with the von Neumann entropy S(\rho) = -\mathrm{Tr}(\rho \log_2(\rho)).

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.

ev(A)

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(r)

Fidelity of two states.

Fidelity of two state operators rho and sigma is defined as F(\rho, \sigma) = \mathrm{Tr} \sqrt{\sqrt{\rho} \sigma \sqrt{\rho}}. For state vectors this is equivalent to the overlap, F = |\langle a|b\rangle|.

Fidelity is symmetric in its arguments and bounded in the interval [0,1]. See [17], chapter 9.2.2.

fix_phase(inplace=False)

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_selection(sys)

Invert and sort a subsystem set.

kraus_propagate(E)

Apply a quantum operation to the state.

Applies the quantum operation E to the state. E = [E_1, E_2, \ldots] is a set of Kraus operators.

locc_convertible(t, sys)

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

lognegativity(sys)

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.

measure(M=None, do=u'R')

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.

  • If no M is given, a full projective measurement in the computational basis is performed.
  • If a list/tuple of subsystems is given as the second parameter, only those subsystems are measured, projectively, in the computational basis.
  • A general measurement may be performed by giving a complete set of measurement operators [M_1, M_2, \ldots] as the second parameter. A POVM can be emulated using M_i = \sqrt{P_i} and discarding the collapsed state.
  • Finally, if the second parameter is a single Hermitian matrix A, the corresponding observable is measured. In this case the second column of p contains the eigenvalue of A corresponding to each measurement result.

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 |k\rangle.

(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(sys)

Negativity of the state.

Returns the negativity of the state wrt. the partitioning given by the listing of subsystems in the vector sys.

See [18], [10]

normalize(inplace=False)

Normalize the state to unity.

plot(symbols=3)

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.

prob()

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.

projector()

Projection operator defined by the state.

Returns the projection operator P defined by the state.

propagate(G, t, out_func=<function <lambda> at 0x3b477d0>, **kwargs)

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

  • Hamiltonian H: \text{out} = \exp(-i H t) |s\rangle (or \exp(-i H t) \rho_s \exp(+i H t))
  • Liouvillian superoperator L: \text{out} = \text{inv\_vec}(\exp(L t) \text{vec}(\rho_s))
  • list consisting of a Hamiltonian followed by Lindblad operators.

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.

ptrace(sys, inplace=False)

Partial trace.

Returns the partial trace of the state over the subsystems listed in the vector sys.

ptranspose(sys, inplace=False)

Partial transpose.

Returns the partial transpose of the state wrt. the subsystems listed in the vector sys.

purity()

Purity of the state.

Returns the purity of a normalized state, p = \mathrm{Tr}(\rho^2). Equivalent to linear entropy, S_l = 1-p.

reorder(perm, inplace=False)

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(sys=None, full=False)

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.

|k\rangle_A = u[:, k],  \qquad |k\rangle_B = v[:, k].

The state is then given by \sum_k \lambda_k |k\rangle_A \otimes |k\rangle_B.

See [17], chapter 2.5.

scott(m)

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.

See [13], [19], [15].

subsystems()

Number of subsystems in the state.

tensor(*arg)

Tensor product of states.

Returns the tensor product state of states s1, s2, ...

to_ket(inplace=False)

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.

to_op(inplace=False)

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()

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_dist(r)

Trace distance of two states.

Trace distance between state operators r and s is defined as D(r, s) = \frac{1}{2} \mathrm{Tr}(\sqrt{A^\dagger A}), where A = r-s.

Equivalently D(r, s) = \frac{1}{2} \sum_k |\lambda_k|, where \lambda_k are the eigenvalues of A (since A is Hermitian). See [17], chapter 9.2.1.

u_propagate(U)

Propagate the state using a unitary.

Propagates the state using the unitary propagator U, returns the resulting state.

var(A)

Variance of an observable in the state.

Returns the variance of the observable A in the state. A has to be Hermitian.

qit.state.fidelity(s, t)

Wrapper for state.fidelity.

qit.state.trace_dist(s, t)

Wrapper for state.trace_dist.