This is an automated email from the git hooks/post-receive script. ppm-guest pushed a commit to annotated tag v0.17 in repository libmath-prime-util-perl.
commit 113f73591ab0b2fd243907a9cea02ff39da50dc5 Author: Dana Jacobsen <d...@acm.org> Date: Wed Dec 12 08:47:56 2012 -0800 Don't use last bit of drand48 --- TODO | 3 +++ lib/Math/Prime/Util.pm | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index c97cc81..76f5081 100644 --- a/TODO +++ b/TODO @@ -40,3 +40,6 @@ - Dynamically use a mulmodadd in PP aks, just like the new C code does. This will mean it'll work for full-size native ints. + +- Add configuration options for rand and randbits (maybe irand and irandrange). + This will help when being used as part of a library. diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm index 66c3fdb..62cc59a 100644 --- a/lib/Math/Prime/Util.pm +++ b/lib/Math/Prime/Util.pm @@ -98,10 +98,13 @@ BEGIN { } # Try to figure out a system rand configuration that works for us. + # Using something other than the craptastic system rand would be best. use Config; $_Config{'system_randbits'} = $Config{'randbits'}; # Keep things in integer range. $_Config{'system_randbits'} = $_Config{'maxbits'}-1 if $_Config{'system_randbits'} >= $_Config{'maxbits'}; + # drand48 has an alternating last bit on almost every system. + $_Config{'system_randbits'}-- if $_Config{'system_randbits'} == 48; no Config; } @@ -830,7 +833,7 @@ sub primes { # I've seen +0, +1, and +2 here. Maurer uses +0. Menezes uses +1. my $q = random_maurer_prime( ($r * $k)->bfloor + 1 ); $q = Math::BigInt->new("$q") unless ref($q) eq 'Math::BigInt'; - my $I = Math::BigInt->new(2)->bpow($k-1)->bdiv(2 * $q)->bfloor; + my $I = Math::BigInt->new(2)->bpow($k-2)->bdiv($q)->bfloor; print "B = $B r = $r k = $k q = $q I = $I\n" if $verbose; # Big GCD's are hugely fast with GMP or Pari, but super slow with Calc. -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits