Skip to content

Commit

Permalink
Merge pull request #189 from diprism/inf_eigenvalue
Browse files Browse the repository at this point in the history
Make check for infinite eigenvalues more reliable
  • Loading branch information
ccshan authored Sep 13, 2024
2 parents 0752fa1 + 7b6544f commit 670eda4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fggs/semirings.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ def solve_thunks(self,
a = make_a()
b = make_b()
try:
a.neg_().diagonal().add_(1)
x = torch.linalg.solve(a, b)
if torch.all(torch.copysign(torch.tensor(1.), x) > 0.): # catches -0.0
return x
if not torch.any(torch.isinf(a)):
a.neg_().diagonal().add_(1)
x = torch.linalg.solve(a, b)
if torch.all(x >= 0.):
return x
except RuntimeError as e:
if '(Cannot allocate memory)' in str(e): raise
pass
Expand Down

0 comments on commit 670eda4

Please sign in to comment.