Previous topic

Quantum states (qit.state)

Next topic

Model Hamiltonians (qit.hamiltonian)

Quantum gates (qit.gate)¶

This module implements many common types of quantum gates (and some other useful linear maps). The returned gates are represented as sparse lmap instances. The data type is float unless complex entries are actually needed.

Contents¶

 dist(A, B) Distance between two unitary lmaps. id(dim) Identity gate. phase(theta[, dim]) Diagonal phase shift gate. qft(*args) Quantum Fourier transform gate. swap(d1, d2) Swap gate. walsh(n) Walsh-Hadamard gate. mod_inc(x, dim[, N]) Modular incrementation gate. mod_mul(x, dim[, N]) Modular multiplication gate. mod_add(dim1, dim2[, N]) Modular adder gate. controlled(U[, ctrl, dim]) Controlled gate. single(L, t, d_in) Single-qudit operator. two(B, t, d_in) Two-qudit operator.
qit.gate.dist(A, B)

Distance between two unitary lmaps.

Returns

qit.gate.id(dim)

Identity gate.

Returns the identity gate I for the specified system. dim is a tuple of subsystem dimensions.

qit.gate.phase(theta, dim=None)

Diagonal phase shift gate.

Returns the (diagonal) phase shift gate U = diag(exp(i*theta)).

qit.gate.qft(*args)

Quantum Fourier transform gate.

Returns the quantum Fourier transform gate for the specified system. dim is a vector of subsystem dimensions. The returned lmap is dense.

qit.gate.swap(d1, d2)

Swap gate.

Returns the swap gate which swaps the order of two subsystems with dimensions [d1, d2].

qit.gate.walsh(n)

Returns the Walsh-Hadamard gate for n qubits. The returned lmap is dense.

Returns the gate U, which, operating on the computational state , produces . dim1 and dim2 are the control and target register dimension vectors.

By default N == prod(dim2). If N is explicitly given we must have N <= prod(dim2), and U will act trivially on target states >= N.

Notes: The modular subtractor gate can be obtained by taking the Hermitian conjugate of mod_add. mod_add(2, 2) is equal to CNOT.

qit.gate.mod_inc(x, dim, N=None)

Modular incrementation gate.

U = mod_inc(x, dim) N == prod(dim) U = mod_inc(x, dim, N) gate dimension prod(dim) must be >= N

Returns the gate U, which, operating on the computational state , increments it by x (mod N): .

If N is given, U will act trivially on computational states >= N.

qit.gate.mod_mul(x, dim, N=None)

Modular multiplication gate.

U = mod_mul(x, dim) N == prod(dim) U = mod_mul(x, dim, N) gate dimension prod(dim) must be >= N

Returns the gate U, which, operating on the computational state , multiplies it by x (mod N): . x and N must be coprime for the operation to be reversible.

If N is given, U will act trivially on computational states >= N.

qit.gate.controlled(U, ctrl=(1, ), dim=None)

Controlled gate.

Returns the (t+1)-qudit controlled-U gate, where t == length(ctrl). U has to be a square matrix.

ctrl is an integer vector defining the control nodes. It has one entry k per control qudit, denoting the required computational basis state for that particular qudit. Value k == -1 denotes no control.

dim is the dimensions vector for the control qudits. If not given, all controls are assumed to be qubits.

Examples:

controlled(NOT, [1]) gives the standard CNOT gate.
controlled(NOT, [1, 1]) gives the Toffoli gate.
qit.gate.single(L, t, d_in)

Single-qudit operator.

Returns the operator U corresponding to the local operator L applied to subsystem t (and identity applied to the remaining subsystems).

d_in is the input dimension vector for U.

qit.gate.two(B, t, d_in)

Two-qudit operator.

Returns the operator U corresponding to the bipartite operator B applied to subsystems t == [t1, t2] (and identity applied to the remaining subsystems).

d_in is the input dimension vector for U.