Skip to content

Commit

Permalink
avoid precision issues by computing in logs directly
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Apr 30, 2018
1 parent ef9afb2 commit f26bb14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fpylll/tools/bkz_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
from copy import copy
from math import log, sqrt, gamma, pi
from math import log, sqrt, lgamma, pi
from collections import OrderedDict

from fpylll.tools.quality import basis_quality
Expand Down Expand Up @@ -80,7 +80,7 @@ def simulate(r, param):
r1 = copy(r)
r2 = copy(r)
c = [rk[-i] - sum(rk[-i:])/i for i in range(1, 46)]
c += [log(gamma(beta/2.+1)**(1./beta)/(sqrt(pi)), 2) for beta in range(46, param.block_size + 1)]
c += [(lgamma(beta/2.+1)*(1./beta) - log(sqrt(pi)))/log(2.) for beta in range(46, param.block_size + 1)]

if param.max_loops:
max_loops = param.max_loops
Expand Down

0 comments on commit f26bb14

Please sign in to comment.