toqito.states.basis¶
A basis state represents the standard basis vectors of some n-dimensional Hilbert Space.
Here, n can be given as a parameter as shown below.
Module Contents¶
- toqito.states.basis.basis(dim, pos)[source]¶
Obtain the ket of dimension dim [@WikiBraKet].
Examples
The standard basis ket vectors given as (|0 rangle) and (|1 rangle) where
]
can be obtained in |toqito⟩ as follows.
Example: Ket basis vector: (|0rangle).
`python exec="1" source="above" from toqito.states import basis print(basis(2, 0)) `Example: Ket basis vector: (|1rangle).
`python exec="1" source="above" from toqito.states import basis print(basis(2, 1)) `- Raises:
ValueError – If the input position is not in the range [0, dim - 1].
- Parameters:
dim (int) – The dimension of the column vector.
pos (int) – 0-indexed position of the basis vector where the 1 will be placed.
- Returns:
The column vector of dimension dim with all entries set to 0 except the entry at pos which is set to 1.
- Return type:
numpy.ndarray