Skip to content

Commit

Permalink
feat: simplified cupy custom matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Jan 21, 2025
1 parent ad362dd commit ecf7312
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/qibojit/backends/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def GeneralizedfSim(self, u, phi):
return np.array([u[0, 0], u[0, 1], u[1, 0], u[1, 1], phase], dtype=self.dtype)


class CustomCupyMatrices(CustomMatrices):
class CustomCupyMatrices(CustomMatrices): # pragma: no cover

def __init__(self, dtype):
super().__init__(dtype)
Expand All @@ -141,17 +141,10 @@ def _cast(self, x, dtype):
return self.cp.array(x, dtype=dtype)

def U1(self, theta):
dtype = getattr(self.cp, self.dtype)
return dtype(self.cp.exp(1j * theta))
return self.cp.array(super().U1(theta), dtype=self.dtype)

def fSim(self, theta, phi):
cost = self.cp.cos(theta) + 0j
isint = -1j * self.cp.sin(theta)
phase = self.cp.exp(-1j * phi)
return self.cp.array([cost, isint, isint, cost, phase], dtype=self.dtype)
return self.cp.array(super().fSim(theta, phi), dtype=self.dtype)

def GeneralizedfSim(self, u, phi):
phase = self.cp.exp(-1j * phi)
return self.cp.array(
[u[0, 0], u[0, 1], u[1, 0], u[1, 1], phase], dtype=self.dtype
)
return self.cp.array(super().GeneralizedfSim(u, phi), dtype=self.dtype)

0 comments on commit ecf7312

Please sign in to comment.