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. IfNone
, defaults to the standard basis.labels (
Optional
[List
]) – Labels for the basis vectors. IfNone
, defaults to integer ordering based on subsystem dimensions.
Methods
- 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 byx.ndim
.- Returns:
A 1-d array representing probabilities computed according to the Born rule.
- 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 ofONBasis
.- Returns:
- An
ONBasis
consisting of the (vector, label) pairs in this one for which condition(label) == True
.
- An
- Return type:
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.