Skip to content

Commit

Permalink
add precision arg
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Oct 4, 2024
1 parent 51b54c2 commit 4a81d92
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/qibojit/backends/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,15 @@ def calculate_matrix_exp(self, a, matrix, eigenvectors=None, eigenvalues=None):
ud = self.cp.transpose(self.cp.conj(eigenvectors))
return self.cp.matmul(eigenvectors, self.cp.matmul(expd, ud))

def calculate_matrix_power(self, matrix, power: Union[float, int]):
def calculate_matrix_power(
self, matrix, power: Union[float, int], precision_singularity: float = 1e-14
):

if isinstance(power, int):
return self.cp.linalg.matrix_power(matrix, power)

copied = self.to_numpy(matrix)
copied = super().calculate_matrix_power(copied, power)
copied = super().calculate_matrix_power(copied, power, precision_singularity)

return self.cast(copied, dtype=copied.dtype)

Expand Down

0 comments on commit 4a81d92

Please sign in to comment.