Skip to content

Commit

Permalink
change float
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Nov 9, 2023
1 parent 589517a commit 43f0d50
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion toqito/state_metrics/matsumoto_fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def matsumoto_fidelity(rho: np.ndarray, sigma: np.ndarray) -> float:
sq_rho = scipy.linalg.sqrtm(rho)
sqinv_rho = scipy.linalg.inv(sq_rho)
except np.linalg.LinAlgError:
sq_rho = scipy.linalg.sqrtm(rho + 1e-8) # if rho is not invertible, add epsilon=1e-8 to it
sq_rho = scipy.linalg.sqrtm(rho + 1e-7) # if rho is not invertible, add epsilon=1e-7 to it
# note if epsilon=1e-8 or smaller, it leads to test failures.
sqinv_rho = scipy.linalg.inv(sq_rho)

sq_mfid = sq_rho @ scipy.linalg.sqrtm(sqinv_rho @ sigma @ sqinv_rho) @ sq_rho
Expand Down

0 comments on commit 43f0d50

Please sign in to comment.