common
are_matrices_equivalent_up_to_global_phase(matrix_a, matrix_b)
Checks whether two matrices are equivalent up to a global phase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix_a
|
NDArray[complex128]
|
first matrix. |
required |
matrix_b
|
NDArray[complex128]
|
second matrix. |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether two matrices are equivalent up to a global phase. |
Source code in opensquirrel/common.py
is_identity_matrix_up_to_a_global_phase(matrix)
Checks whether matrix is an identity matrix up to a global phase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
NDArray[complex128]
|
matrix to check. |
required |
Returns: Whether matrix is an identity matrix up to a global phase.
Source code in opensquirrel/common.py
normalize_angle(x)
Normalize the angle to be in between the range of \((-\pi, \pi]\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
SupportsFloat
|
value to normalize. |
required |
Returns:
Type | Description |
---|---|
float
|
The normalized angle. |
Source code in opensquirrel/common.py
repr_round(value, decimals=REPR_DECIMALS)
Given a numerical value (of type float
, Axis
, or NDArray[np.complex128]
):
- rounds it to REPR_DECIMALS
,
- converts it to string, and
- removes the newlines.
Returns:
Type | Description |
---|---|
str
|
A single-line string representation of a numerical value. |