]> Cypherpunks repositories - gostls13.git/commit
big: implemented Karatsuba multiplication
authorRobert Griesemer <gri@golang.org>
Wed, 28 Apr 2010 02:16:08 +0000 (19:16 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 28 Apr 2010 02:16:08 +0000 (19:16 -0700)
commitb2183701c08328c533c022f3609a0bff19061998
tree42e388e27029f269f35eab8c1f99958dfc57308f
parentdc606a20ceeb48d68616f46f6ed24b1f5f0afe78
big: implemented Karatsuba multiplication

Plus:
- calibration "test" - include in tests with gotest -calibrate
- basic Mul benchmark
- extra multiplication tests
- various cleanups

This change improves multiplication speed of numbers >= 30 words
in length (current threshold; found empirically with calibrate):

The multiplication benchmark (multiplication of a variety of long numbers)
improves by ~35%, individual multiplies can be significantly faster.

gotest -benchmarks=Mul
big.BenchmarkMul      500    6829290 ns/op (w/ Karatsuba)
big.BenchmarkMul      100   10600760 ns/op

There's no impact on pidigits for -n=10000 or -n=20000
because the operands are are too small.

R=rsc
CC=golang-dev
https://golang.org/cl/1004042
src/pkg/big/calibrate_test.go [new file with mode: 0644]
src/pkg/big/int.go
src/pkg/big/int_test.go
src/pkg/big/nat.go
src/pkg/big/nat_test.go