toqito.state_ops.normalize

Normalize quantum state vectors.

Module Contents

toqito.state_ops.normalize.normalize(vector, *, tol=1e-08)[source]

Return a normalized copy of the input state vector.

The input may be a one-dimensional array or a column/row vector. A zero vector raises ValueError.

Examples

```python exec=”1” source=”above” import numpy as np from toqito.state_ops import normalize

v = np.array([1, 1], dtype=np.complex128) print(normalize(v)) ```

Raises:

ValueError – If the input is not vector-shaped or has vanishing norm.

Parameters:
  • vector (Sequence[complex] | numpy.ndarray) – State vector expressed as a 1D array or column/row vector.

  • tol (float) – Numerical tolerance used to detect zero-norm inputs.

Returns:

Normalized vector as a 1D NumPy array.

Return type:

numpy.ndarray