canonical_gate
CanonicalAxis
Bases: BaseAxis
Source code in opensquirrel/ir/semantics/canonical_gate.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
accept
in_weyl_chamber
staticmethod
Checks if the canonical axis is in the Weyl chamber.
Returns:
| Type | Description |
|---|---|
bool
|
True if the canonical axis is in the Weyl chamber, False otherwise. |
Source code in opensquirrel/ir/semantics/canonical_gate.py
parse
staticmethod
Parse and validate an AxisLike.
Checks if the axis can be cast to a 1DArray of length 3, raise an error otherwise. After casting to an array, the elements of the canonical axis are restricted to the Weyl chamber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
AxisLike
|
Axis to validate and parse. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Parsed axis to 1DArray of length 3. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the axis cannot be cast to an ArrayLike. |
ValueError
|
If the axis cannot be flattened to length 3. |
Source code in opensquirrel/ir/semantics/canonical_gate.py
restrict_to_weyl_chamber
staticmethod
Restricts the given axis to the Weyl chamber.
The six rules that are (implicitly) used are:
- The canonical parameters are periodic with a period of 2 (neglecting a global phase).
- \(\text{Can}(t_x, t_y, t_z)\sim\text{Can}(t_x - 1, t_y, t_z)\) (for any parameter)
- \(\text{Can}(t_x, t_y, t_z)\sim\text{Can}(t_x, -t_y, -t_z)\) (for any pair of parameters)
- \(\text{Can}(t_x, t_y, t_z)\sim\text{Can}(t_y, t_x, t_z)\) (for any pair of parameters)
- \(\text{Can}(t_x, t_y, 0)\sim\text{Can}(1 - t_x, t_y, 0)\)
- \(\text{Can}(t_x, t_y, t_z) * \text{Can}(t_x', t_y', t_z') = \text{Can}(t_x + t_x', t_y + t_y', t_z + t_z')\)
Note
Based on the rules described in Quantum Gates by G.E. Crooks (2024), Section 5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
NDArray[float64]
|
Axis to restrict to the Weyl chamber. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
Axis restricted to the Weyl chamber. |
Source code in opensquirrel/ir/semantics/canonical_gate.py
CanonicalGateSemantic
Bases: GateSemantic
Source code in opensquirrel/ir/semantics/canonical_gate.py
__eq__
Checks if two CanonicalGateSemantic instances are equal.
Returns:
| Type | Description |
|---|---|
bool
|
True if both have the same axis and rotations, False otherwise. |
Source code in opensquirrel/ir/semantics/canonical_gate.py
accept
is_identity
Checks if the canonical gate semantic represents an identity operation.
Returns:
| Type | Description |
|---|---|
bool
|
True if the canonical gate semantic represents an identity operation, False otherwise. |