Skip to content

Commit

Permalink
Merge pull request #168 from qiboteam/sxdg
Browse files Browse the repository at this point in the history
Add SXDG gate
  • Loading branch information
Simone-Bordoni authored Feb 15, 2024
2 parents 48b5166 + 7b819b9 commit aaec656
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/qibojit/backends/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def CZ(self):
def CSX(self):
return self.SX

@cached_property
def CSXDG(self):
return self.SXDG

def CRX(self, theta):
return self.RX(theta)

Expand Down
24 changes: 24 additions & 0 deletions src/qibojit/tests/test_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,30 @@ def test_apply_csx(backend, nqubits, targets, dtype):
backend.assert_allclose(state, target_state, atol=ATOL.get(dtype))


@pytest.mark.parametrize(
("nqubits", "targets"),
[
(2, [0, 1]),
(3, [0, 2]),
(4, [1, 3]),
(3, [1, 2]),
(4, [0, 2]),
(4, [2, 3]),
(5, [3, 4]),
(6, [1, 4]),
],
)
def test_apply_csxdg(backend, nqubits, targets, dtype):
tbackend = NumpyBackend()
state = random_statevector(2**nqubits, backend=tbackend).astype(dtype)
gate = gates.CSXDG(*targets)

set_precision(dtype, backend, tbackend)
target_state = tbackend.apply_gate(gate, np.copy(state), nqubits)
state = backend.apply_gate(gate, np.copy(state), nqubits)
backend.assert_allclose(state, target_state, atol=ATOL.get(dtype))


@pytest.mark.parametrize(
("nqubits", "targets"),
[
Expand Down

0 comments on commit aaec656

Please sign in to comment.