From 6dfd2ca351b55c0aaf1b3f8c14ac18ab843851ed Mon Sep 17 00:00:00 2001 From: Renato Mello Date: Thu, 12 Oct 2023 10:40:48 +0400 Subject: [PATCH] `backenc.calculate_norm` uses `numpy.linalg.norm` --- src/qibo/backends/numpy.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/qibo/backends/numpy.py b/src/qibo/backends/numpy.py index b0447bd56e..96348b6771 100644 --- a/src/qibo/backends/numpy.py +++ b/src/qibo/backends/numpy.py @@ -673,13 +673,14 @@ def entanglement_entropy(self, rho): entropy = self.np.sum(masked_eigvals * spectrum) / self.np.log(2.0) return entropy, spectrum - def calculate_norm(self, state): + def calculate_norm(self, state, order=None): + """""" state = self.cast(state) - return self.np.sqrt(self.np.sum(self.np.abs(state) ** 2)) + return self.np.linalg.norm(state, ord=order) - def calculate_norm_density_matrix(self, state): + def calculate_norm_density_matrix(self, state, order="nuc"): state = self.cast(state) - return self.np.trace(state) + return self.np.linalg.norm(state, ord=order) def calculate_overlap(self, state1, state2): state1 = self.cast(state1)