Skip to content

Use XXPLUSYY gate and add XXMINUSYY gate #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 15, 2025
Merged
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
11 changes: 7 additions & 4 deletions src/qiskit_quimb/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# that they have been altered from the originals.
from __future__ import annotations

import math
from collections.abc import Iterator, Sequence
from typing import Any, Callable

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


@_register_gate_func("xx_minus_yy")
def _(op: Instruction, qubits: Sequence[int], kwargs: dict[str, Any]):
theta, beta = op.params
return quimb.tensor.Gate("XXMINUSYY", params=[theta, beta], qubits=qubits, **kwargs)


@_register_gate_func("xx_plus_yy")
def _(op: Instruction, qubits: Sequence[int], kwargs: dict[str, Any]):
theta, beta = op.params
return quimb.tensor.Gate(
"GIVENS2", params=[0.5 * theta, beta + 0.5 * math.pi], qubits=qubits, **kwargs
)
return quimb.tensor.Gate("XXPLUSYY", params=[theta, beta], qubits=qubits, **kwargs)


@_register_gate_func("y")
Expand Down
4 changes: 4 additions & 0 deletions tests/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
U2Gate,
U3Gate,
XGate,
XXMinusYYGate,
XXPlusYYGate,
YGate,
ZGate,
Expand All @@ -62,6 +63,9 @@ def test_quimb_circuit():
circuit.append(XXPlusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [b, c])
circuit.append(XXPlusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [a, b])
circuit.append(XXPlusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [c, d])
circuit.append(XXMinusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [b, c])
circuit.append(XXMinusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [a, b])
circuit.append(XXMinusYYGate(rng.uniform(-10, 10), rng.uniform(-10, 10)), [c, d])
circuit.append(CPhaseGate(rng.uniform(-10, 10)), [b, c])
circuit.append(CPhaseGate(rng.uniform(-10, 10)), [a, b])
circuit.append(CPhaseGate(rng.uniform(-10, 10)), [c, d])
Expand Down