symop.polynomial.channels.unitaries.conventions¶
Matrix validation utilities.
Helper functions used by the unitary construction modules to validate matrix shape, dimensions, and optional unitarity constraints.
Functions
|
Raise ValueError unless U has shape (n, n). |
Raise ValueError unless U is a square matrix. |
|
|
Optionally validate U is unitary, i.e. U^H U = I. |
- require_dim(U: ndarray, *, n: int) None¶
Raise ValueError unless U has shape (n, n).
- Parameters:
- Raises:
ValueError – If shape mismatch.
- Return type:
None
- require_square(U: ndarray) None¶
Raise ValueError unless U is a square matrix.
- Parameters:
U (
ndarray) – Candidate matrix.- Raises:
ValueError – If U is not 2D or not square.
- Return type:
None
- require_unitary_optional(U: ndarray, *, check_unitary: bool = False, atol: float = 1e-10) None¶
Optionally validate U is unitary, i.e. U^H U = I.
This is deliberately optional because (a) it costs time, and (b) some uses may pass approximate numerics.
- Parameters:
- Raises:
ValueError – If check_unitary is True and U is not unitary within atol.
- Return type:
None