From 23ccda942045d9b4b95ecbc88a0cafff8684d473 Mon Sep 17 00:00:00 2001 From: simone bordoni Date: Wed, 28 Feb 2024 17:26:49 +0400 Subject: [PATCH] solved errors in evolution --- src/qibo/hamiltonians/hamiltonians.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qibo/hamiltonians/hamiltonians.py b/src/qibo/hamiltonians/hamiltonians.py index 179895f751..578dd2648d 100644 --- a/src/qibo/hamiltonians/hamiltonians.py +++ b/src/qibo/hamiltonians/hamiltonians.py @@ -248,7 +248,12 @@ def __mul__(self, o): if self.backend.np.real(o) >= 0: # TODO: check for side effects K.qnp r._eigenvalues = o * self._eigenvalues elif not self.backend.issparse(self.matrix): - r._eigenvalues = o * self._eigenvalues[::-1] + if self.backend.__class__.__name__ == "PyTorchBackend": + import torch + + r._eigenvalues = o * torch.flip(self._eigenvalues, [0]) + else: + r._eigenvalues = o * self._eigenvalues[::-1] if self._eigenvectors is not None: if self.backend.np.real(o) > 0: # TODO: see above r._eigenvectors = self._eigenvectors