diff --git a/src/qibojit/backends/matrices.py b/src/qibojit/backends/matrices.py index 6bf2ff00..099c3a76 100644 --- a/src/qibojit/backends/matrices.py +++ b/src/qibojit/backends/matrices.py @@ -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) diff --git a/src/qibojit/tests/test_gates.py b/src/qibojit/tests/test_gates.py index 0aef558e..e086efb3 100644 --- a/src/qibojit/tests/test_gates.py +++ b/src/qibojit/tests/test_gates.py @@ -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"), [