Skip to content

Commit

Permalink
backenc.calculate_norm uses numpy.linalg.norm
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Oct 12, 2023
1 parent f45aa26 commit 6dfd2ca
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/qibo/backends/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6dfd2ca

Please sign in to comment.