Skip to content
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

Add SX and SXDG gates #277

Merged
merged 2 commits into from
Feb 12, 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
9 changes: 9 additions & 0 deletions quimb/tensor/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [ ] multi qubit gates via MPO for MPS simulation
"""

import cmath
import functools
import itertools
import math
Expand Down Expand Up @@ -419,6 +420,8 @@
register_constant_gate("SDG", qu.S_gate().H, 1)
register_constant_gate("T", qu.T_gate(), 1)
register_constant_gate("TDG", qu.T_gate().H, 1)
register_constant_gate("SX", cmath.rect(1, 0.25 * math.pi) * qu.Xsqrt(), 1)
register_constant_gate("SXDG", cmath.rect(1, -0.25 * math.pi) * qu.Xsqrt().H, 1)
register_constant_gate("X_1_2", qu.Xsqrt(), 1, "X_1/2")
register_constant_gate("Y_1_2", qu.Ysqrt(), 1, "Y_1/2")
register_constant_gate("Z_1_2", qu.Zsqrt(), 1, "Z_1/2")
Expand Down Expand Up @@ -2038,6 +2041,12 @@
def tdg(self, i, gate_round=None, **kwargs):
self.apply_gate("TDG", i, gate_round=gate_round, **kwargs)

def sx(self, i, gate_round=None, **kwargs):
self.apply_gate("SX", i, gate_round=gate_round, **kwargs)

Check warning on line 2045 in quimb/tensor/circuit.py

View check run for this annotation

Codecov / codecov/patch

quimb/tensor/circuit.py#L2045

Added line #L2045 was not covered by tests

def sxdg(self, i, gate_round=None, **kwargs):
self.apply_gate("SXDG", i, gate_round=gate_round, **kwargs)

Check warning on line 2048 in quimb/tensor/circuit.py

View check run for this annotation

Codecov / codecov/patch

quimb/tensor/circuit.py#L2048

Added line #L2048 was not covered by tests

def x_1_2(self, i, gate_round=None, **kwargs):
self.apply_gate("X_1_2", i, gate_round=gate_round, **kwargs)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_tensor/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,12 @@ def test_all_gate_methods(self, Circ):
("y", 1, 0),
("z", 1, 0),
("s", 1, 0),
("sdg", 1, 0),
("t", 1, 0),
("tdg", 1, 0),
("h", 1, 0),
("sx", 1, 0),
("sxdg", 1, 0),
("iden", 1, 0),
("x_1_2", 1, 0),
("y_1_2", 1, 0),
Expand Down
Loading