common
are_matrices_equivalent_up_to_global_phase
are_matrices_equivalent_up_to_global_phase(
matrix_a: NDArray[complex128],
matrix_b: NDArray[complex128],
) -> bool
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
|
True if two matrices are equivalent up to a global phase, otherwise False. |
Source code in opensquirrel/common.py
is_identity_matrix_up_to_a_global_phase
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:
| Type | Description |
|---|---|
bool
|
True if matrix is an identity matrix up to a global phase, otherwise False. |
Source code in opensquirrel/common.py
normalize_angle
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
Given a numerical value:
- rounds it to
REPR_DECIMALS, - converts it to string, and
- removes any newlines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float | BaseAxis | NDArray[complex128]
|
The numerical value to represent. |
required |
decimals
|
int
|
Number of decimals to round to. Default is |
REPR_DECIMALS
|
Returns:
| Type | Description |
|---|---|
str
|
A single-line string representation of a rounded numerical value. |