toqito.state_ops.normalize ========================== .. py:module:: toqito.state_ops.normalize .. autoapi-nested-parse:: Normalize quantum state vectors. Module Contents --------------- .. py:function:: normalize(vector, *, tol = 1e-08) 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`. .. rubric:: 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. :param vector: State vector expressed as a 1D array or column/row vector. :param tol: Numerical tolerance used to detect zero-norm inputs. :returns: Normalized vector as a 1D NumPy array.