Skip to content

fix(log): bypass ValueError #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions estimator/lwe_primal.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def svp_dimension(cls, r, D):
:param r: squared Gram-Schmidt norms

"""
from math import lgamma, log, exp, pi
from math import lgamma, exp, pi, log as math_log

def ball_log_vol(n):
return (n / 2.0) * log(pi) - lgamma(n / 2.0 + 1)
Expand All @@ -299,7 +299,13 @@ def gaussian_heuristic_log_input(r):
return exp(log_gh)

d = len(r)
r = [log(x) for x in r]

try:
r = [math_log(x) for x in r]

except ValueError:
# use slower one when the above crashes due to small values
r = [log(x) for x in r]

if d > 4096:
for i, _ in enumerate(r):
Expand Down
Loading