ONBasis

class ONBasis(subsystems, basis_vectors=None, labels=None)[source]

Bases: object

Represents a list of orthonormal vectors.

An orthonormal basis specified as a 2d array whose columns are the vectors.

Parameters:
  • subsystems (List[Subsystem]) – A list of Subsystem instances. Tensor product ordering is assumed to be reversed.

  • basis_vectors (Optional[ndarray]) – The vectors given as a 2d array, with the vectors being the columns. If None, defaults to the standard basis.

  • labels (Optional[List]) – Labels for the basis vectors. If None, defaults to integer ordering based on subsystem dimensions.

Methods

decompose(x)[source]

Return the coefficients of the projection of a vector x in the basis.

probabilities(x)[source]

Treating x as a state vector or density matrix, compute the probabilities of observing the outcomes of a measurement defined by the basis vectors.

Parameters:

x (ndarray) – The statevector or density matrix. Which case is determined by x.ndim.

Returns:

A 1-d array representing probabilities computed according to the Born rule.

project(x)[source]

Project a vector x onto the subspace spanned by the basis.

subset(condition)[source]

Get a new ONBasis consisting of a subset of this one filtered according to the condition function defined on the basis labels.

Parameters:

condition (Callable) – A boolean-valued function on the labels of this instance of ONBasis.

Returns:

An ONBasis consisting of the (vector, label) pairs in this one for which

condition(label) == True.

Return type:

ONBasis

Attributes

basis_vectors

Basis vectors as the columns of an 2-d array.

basis_vectors_adj

Adjoint of the basis vectors matrix.

labels

Basis element labels.

projection

Matrix for the orthogonal projection onto the subspace spanned by the basis.

subsystems

Subsystems representing the tensor product space on which the basis is defined.