• David Leon Gil's avatar
    math/big: use optimized formula in ModSqrt for 3 mod 4 primes · ea0491b7
    David Leon Gil authored
    For primes which are 3 mod 4, using Tonelli-Shanks is slower
    and more complicated than using the identity
    
         a**((p+1)/4) mod p == sqrt(a)
    
    For 2^450-2^225-1 and 2^10860-2^5430-1, which are 3 mod 4:
    
    BenchmarkModSqrt225_TonelliTri      1000     1135375 ns/op
    BenchmarkModSqrt225_3Mod4          10000      156009 ns/op
    BenchmarkModSqrt5430_Tonelli           1  3448851386 ns/op
    BenchmarkModSqrt5430_3Mod4             2   914616710 ns/op
    
    ~2.6x to 7x faster.
    
    Fixes #11437 (which is a prime choice of issues to fix)
    
    Change-Id: I813fb29454160483ec29825469e0370d517850c2
    Reviewed-on: https://go-review.googlesource.com/11522Reviewed-by: 's avatarAdam Langley <agl@golang.org>
    ea0491b7
Name
Last commit
Last update
..
accuracy_string.go Loading commit data...
arith.go Loading commit data...
arith_386.s Loading commit data...
arith_amd64.s Loading commit data...
arith_amd64p32.s Loading commit data...
arith_arm.s Loading commit data...
arith_arm64.s Loading commit data...
arith_decl.go Loading commit data...
arith_decl_pure.go Loading commit data...
arith_ppc64x.s Loading commit data...
arith_test.go Loading commit data...
bits_test.go Loading commit data...
calibrate_test.go Loading commit data...
decimal.go Loading commit data...
decimal_test.go Loading commit data...
example_test.go Loading commit data...
float.go Loading commit data...
float_test.go Loading commit data...
floatconv.go Loading commit data...
floatconv_test.go Loading commit data...
floatexample_test.go Loading commit data...
ftoa.go Loading commit data...
gcd_test.go Loading commit data...
hilbert_test.go Loading commit data...
int.go Loading commit data...
int_test.go Loading commit data...
intconv.go Loading commit data...
intconv_test.go Loading commit data...
nat.go Loading commit data...
nat_test.go Loading commit data...
natconv.go Loading commit data...
natconv_test.go Loading commit data...
rat.go Loading commit data...
rat_test.go Loading commit data...
ratconv.go Loading commit data...
ratconv_test.go Loading commit data...
roundingmode_string.go Loading commit data...