states.basis

Basis state.

Module Contents

Functions

basis(dim, pos)

Obtain the ket of dimension dim [1].

states.basis.basis(dim, pos)

Obtain the ket of dimension dim [1].

Examples

The standard basis bra vectors given as \(|0 \rangle\) and \(|1 \rangle\) where

\[|0 \rangle = \left[1, 0 \right]^{\text{T}} \quad \text{and} \quad |1 \rangle = \left[0, 1 \right]^{\text{T}},\]

can be obtained in toqito as follows.

Example: Ket basis vector: \(|0\rangle\).

>>> from toqito.states import basis
>>> basis(2, 0)
array([[1],
       [0]])

Example: Ket basis vector: \(|1\rangle\).

>>> from toqito.states import basis
>>> basis(2, 1)
array([[0],
       [1]])

References

[1] (1,2)

Wikipedia. Bra-ket notation. https://en.wikipedia.org/wiki/Bra.

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) – The position in which to place a 1.

Returns:

The column vector of dimension dim with all entries set to 0 except the entry at position 1.

Return type:

numpy.ndarray