Skip to content

Commit

Permalink
Update thewalrus/decompositions.py
Browse files Browse the repository at this point in the history
Co-authored-by: Eli Bourassa <53090166+elib20@users.noreply.github.com>
  • Loading branch information
RyosukeNORO and elib20 authored Jul 4, 2024
1 parent 9117198 commit 1609f13
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion thewalrus/decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def takagi(A, svd_order=True, tol=1e-16):
A = np.triu(A) + np.triu(A, k=1).T

# Kill small values in the matrix A. This was installed because takagi decomposition did not work at some matrix A with small values.
A = np.where(np.abs(A.real) <= tol, 0, A.real) + np.where(np.abs(A.imag) <= tol, 0, A.imag)
rtol = tol * np.amax(np.abs(A))
A = np.where(np.abs(A.real) <= rtol, 0, A.real) + np.where(np.abs(A.imag) <= rtol, 0, A.imag)

if np.allclose(A, 0):
return np.zeros(n), np.eye(n)
Expand Down

0 comments on commit 1609f13

Please sign in to comment.