qit.utils

Utilities

This module contains utility functions which do not logically fit anywhere else.

Mathematical utilities

gcd(a, b)

Greatest common divisor.

lcm(a, b)

Least common multiple.

majorize(x, y[, tol])

Majorization partial order of real vectors.

Matrix functions

comm(A, B)

Array commutator.

acomm(A, B)

Array anticommutator.

mkron(*arg)

This is how kron should work, dammit.

tensorsum(*arg)

Like kron but adding instead of multiplying.

rank(A[, tol])

Matrix rank.

orth(A[, tol, kernel, spectrum])

Construct an orthonormal basis for the range of A using SVD

nullspace(A[, tol, spectrum])

Kernel of a matrix.

nullspace_hermitian(A[, tol])

Kernel of a superoperator matrix restricted to the Hermitian subspace.

projector(v)

Projector corresponding to vector v.

eighsort(A)

Returns eigenvalues and eigenvectors of a Hermitian matrix, sorted in nonincreasing order.

expv(t, A, v[, tol, m, iteration])

Multiply a vector by an exponentiated matrix.

Random matrices

rand_hermitian(n)

Random Hermitian n*n matrix.

rand_U(n)

Random U(n) matrix.

rand_SU(n)

Random SU(n) matrix.

rand_U1(n)

Random diagonal unitary matrix.

rand_pu(n)

Random n-partition of unity.

rand_positive(n)

Random n*n positive semidefinite matrix.

rand_GL(n)

Random GL(n, C) matrix.

rand_SL(n)

Random SL(n, C) matrix.

Superoperators

vec(rho)

Flattens a matrix into a vector.

inv_vec(v[, dim])

Reshapes a vector into a matrix.

lmul(L[, q])

Superoperator equivalent for multiplying from the left.

rmul(R[, p])

Superoperator equivalent for multiplying from the right.

lrmul(L, R)

Superoperator equivalent for multiplying both from left and right.

superop_lindblad(A[, H])

Liouvillian superoperator for a set of Lindblad operators.

superop_fp(L[, tol])

Fixed point states of a Liouvillian superoperator.

superop_to_choi(L)

Convert a Liouvillian superoperator to a Choi matrix.

Physics

angular_momentum(*args)

Angular momentum matrices.

boson_ladder(*args)

Bosonic ladder operators.

fermion_ladder(*args)

Fermionic ladder operators.

Bases, decompositions

spectral_decomposition(A[, tol])

Spectral decomposition of a Hermitian matrix.

gellmann(*args)

Gell-Mann matrices.

tensorbasis(n[, d, get_locality, only_local])

Hermitian tensor-product basis for End(H).

Miscellaneous

copy_memoize(func)

Memoization decorator for functions with immutable args, returns deep copies.

op_list(G, dim)

Operator consisting of k-local terms, given as a list.

cdot(v, A)

Real dot product of a vector and a tuple of operators.

qubits(n)

Dimension vector for an all-qubit system.

R_nmr(theta, phi)

SU(2) rotation \(\theta_\phi\) (NMR notation).

Rx(theta)

SU(2) x-rotation.

Ry(theta)

SU(2) y-rotation.

Rz(theta)

SU(2) z-rotation.

trisurf(p, max_dist)

Populates a 2D triangular surface with evenly spaced points for Delaunay triangulation.

Functions

R_nmr(theta, phi)

SU(2) rotation \(\theta_\phi\) (NMR notation).

Rx(theta)

SU(2) x-rotation.

Ry(theta)

SU(2) y-rotation.

Rz(theta)

SU(2) z-rotation.

acomm(A, B)

Array anticommutator.

angular_momentum(*args)

Angular momentum matrices.

boson_ladder(*args)

Bosonic ladder operators.

cdot(v, A)

Real dot product of a vector and a tuple of operators.

comm(A, B)

Array commutator.

copy_memoize(func)

Memoization decorator for functions with immutable args, returns deep copies.

eighsort(A)

Returns eigenvalues and eigenvectors of a Hermitian matrix, sorted in nonincreasing order.

expv(t, A, v[, tol, m, iteration])

Multiply a vector by an exponentiated matrix.

fermion_ladder(*args)

Fermionic ladder operators.

gcd(a, b)

Greatest common divisor.

gellmann(*args)

Gell-Mann matrices.

inv_vec(v[, dim])

Reshapes a vector into a matrix.

lcm(a, b)

Least common multiple.

lmul(L[, q])

Superoperator equivalent for multiplying from the left.

lrmul(L, R)

Superoperator equivalent for multiplying both from left and right.

majorize(x, y[, tol])

Majorization partial order of real vectors.

mkron(*arg)

This is how kron should work, dammit.

nullspace(A[, tol, spectrum])

Kernel of a matrix.

nullspace_hermitian(A[, tol])

Kernel of a superoperator matrix restricted to the Hermitian subspace.

op_list(G, dim)

Operator consisting of k-local terms, given as a list.

orth(A[, tol, kernel, spectrum])

Construct an orthonormal basis for the range of A using SVD

projector(v)

Projector corresponding to vector v.

qubits(n)

Dimension vector for an all-qubit system.

rand_GL(n)

Random GL(n, C) matrix.

rand_SL(n)

Random SL(n, C) matrix.

rand_SU(n)

Random SU(n) matrix.

rand_U(n)

Random U(n) matrix.

rand_U1(n)

Random diagonal unitary matrix.

rand_hermitian(n)

Random Hermitian n*n matrix.

rand_positive(n)

Random n*n positive semidefinite matrix.

rand_pu(n)

Random n-partition of unity.

rank(A[, tol])

Matrix rank.

rmul(R[, p])

Superoperator equivalent for multiplying from the right.

spectral_decomposition(A[, tol])

Spectral decomposition of a Hermitian matrix.

superop_fp(L[, tol])

Fixed point states of a Liouvillian superoperator.

superop_lindblad(A[, H])

Liouvillian superoperator for a set of Lindblad operators.

superop_to_choi(L)

Convert a Liouvillian superoperator to a Choi matrix.

tensorbasis(n[, d, get_locality, only_local])

Hermitian tensor-product basis for End(H).

tensorsum(*arg)

Like kron but adding instead of multiplying.

trisurf(p, max_dist)

Populates a 2D triangular surface with evenly spaced points for Delaunay triangulation.

vec(rho)

Flattens a matrix into a vector.