Skip to content

Commit af37411

Browse files
authored
Use XXPLUSYY gate and add XXMINUSYY gate (#21)
* use XXPLUSYY gate * add XXMINUSYY gate * lint
1 parent 38727c7 commit af37411

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/qiskit_quimb/gate.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# that they have been altered from the originals.
1010
from __future__ import annotations
1111

12-
import math
1312
from collections.abc import Iterator, Sequence
1413
from typing import Any, Callable
1514

@@ -191,12 +190,16 @@ def _(op: Instruction, qubits: Sequence[int], kwargs: dict[str, Any]):
191190
return quimb.tensor.Gate("X", params=[], qubits=qubits, **kwargs)
192191

193192

193+
@_register_gate_func("xx_minus_yy")
194+
def _(op: Instruction, qubits: Sequence[int], kwargs: dict[str, Any]):
195+
theta, beta = op.params
196+
return quimb.tensor.Gate("XXMINUSYY", params=[theta, beta], qubits=qubits, **kwargs)
197+
198+
194199
@_register_gate_func("xx_plus_yy")
195200
def _(op: Instruction, qubits: Sequence[int], kwargs: dict[str, Any]):
196201
theta, beta = op.params
197-
return quimb.tensor.Gate(
198-
"GIVENS2", params=[0.5 * theta, beta + 0.5 * math.pi], qubits=qubits, **kwargs
199-
)
202+
return quimb.tensor.Gate("XXPLUSYY", params=[theta, beta], qubits=qubits, **kwargs)
200203

201204

202205
@_register_gate_func("y")

tests/circuit_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
U2Gate,
4141
U3Gate,
4242
XGate,
43+
XXMinusYYGate,
4344
XXPlusYYGate,
4445
YGate,
4546
ZGate,
@@ -62,6 +63,9 @@ def test_quimb_circuit():
6263
circuit.append(XXPlusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [b, c])
6364
circuit.append(XXPlusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [a, b])
6465
circuit.append(XXPlusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [c, d])
66+
circuit.append(XXMinusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [b, c])
67+
circuit.append(XXMinusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [a, b])
68+
circuit.append(XXMinusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [c, d])
6569
circuit.append(CPhaseGate(rng.uniform(-10, 10)), [b, c])
6670
circuit.append(CPhaseGate(rng.uniform(-10, 10)), [a, b])
6771
circuit.append(CPhaseGate(rng.uniform(-10, 10)), [c, d])

0 commit comments

Comments
 (0)