Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cirq-core/cirq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
IdentityGate,
InterchangeableQubitsGate,
ISWAP,
ISWAP_INV,
ISwapPowGate,
KrausChannel,
LinearCombinationOfGates,
Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@

from cirq.ops.swap_gates import (
ISWAP,
ISWAP_INV,
ISwapPowGate,
riswap,
SQRT_ISWAP,
Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/ops/pauli_string_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,7 @@ def _decompose_(self, qubits):
cirq.CNOT,
cirq.CZ,
cirq.ISWAP,
cirq.ISWAP_INV,
cirq.ISWAP**-1,
cirq.SWAP,
cirq.XX**0.5,
Expand Down
16 changes: 16 additions & 0 deletions cirq-core/cirq/ops/swap_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
This module creates Gate instances for the following gates:
SWAP: the swap gate.
ISWAP: a swap gate with a phase on the swapped subspace.
ISWAP_INV: inverse of the ISWAP gate.
SQRT_ISWAP: square root of the ISWAP gate.
SQRT_ISWAP_INV: inverse square root of the ISWAP gate.

Expand Down Expand Up @@ -319,6 +320,21 @@ def riswap(rads: value.TParamVal) -> ISwapPowGate:
""",
)

ISWAP_INV = ISwapPowGate(exponent=-1)
document(
ISWAP_INV,
"""The inverse of iswap gate.

Matrix:
```
[[1, 0, 0, 0],
[0, 0, -i, 0],
[0, -i, 0, 0],
[0, 0, 0, 1]]
```
""",
)

SQRT_ISWAP = ISwapPowGate(exponent=0.5)
document(
SQRT_ISWAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def test_wait_gate_multi_qubit():
(cirq.ISWAP**-0.5, np.pi / 4, 0),
(cirq.ISWAP**1.0, -np.pi / 2, 0),
(cirq.ISWAP**-1.0, np.pi / 2, 0),
(cirq.ISWAP_INV, np.pi / 2, 0),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move down below other ISWAP. Also considering adding another case like cirq.ISWAP_INV ** 0.5

(cirq.ISWAP**0.0, 0, 0),
(cirq.CZ, 0, np.pi),
(cirq.CZ**-1.0, 0, np.pi),
Expand Down