qugrad.HilbertSpace¶
- class qugrad.HilbertSpace(basis: ndarray[int])[source]¶
Bases:
objectRepresents a Hilbert space with a prefered basis indexed by non-negative integers.
Note
The class also can be treated as an iterator and will return
basisas the iterator.—
Attributes
An array of positive integers labeling the Hilbert space basis
The Hilbert space dimension
An array satisfying the property
self.inverse[self.basis[i]]=iMethods
Initialises a new
HilbertSpace.Returns a column vector represnetation corresponding to the input basis state label.
Generates a new subspace by filtering the basis state labels.
Generates a string (list of strings) that represent the state(s).
- __init__(basis: ndarray[int])[source]¶
Initialises a new
HilbertSpace.- Parameters:
basis (NDArray[Shape[
dim], int]) – The labels for the basis vectors.
- basis_vector(basis_state_label: int) ndarray[complex128][source]¶
Returns a column vector represnetation corresponding to the input basis state label.
- Parameters:
basis_state_label (int) – A positive integer denoting the label of the basis state to generate the basis vector for.
- Returns:
The basis vector corresponding to the input basis state label.
- Return type:
NDArray[Shape[
dim], np.complex128]
- get_subspace(filter: ndarray[bool]) HilbertSpace[source]¶
Generates a new subspace by filtering the basis state labels.
- Parameters:
filter (NDArray[Shape[
dim], bool]) –Trueentries are retained in the new subspace.- Returns:
The filtered subspace.
- Return type:
- labels(states: int | list[int] | None = None) str | list[str][source]¶
Generates a string (list of strings) that represent the state(s).
- Parameters:
states (int | list[int], optional) – The state(s) to label. If
Nonethen the labels for all states inbasisare returned. By defaultNone.- Returns:
The label(s) for the specified states.
- Return type:
str | list[str]
- property basis: ndarray[int]¶
An array of positive integers labeling the Hilbert space basis
- property dim¶
The Hilbert space dimension
- property inverse: ndarray[int]¶
An array satisfying the property
self.inverse[self.basis[i]]=i