Involved Source Filesarith_decl.gofermat.go
Package bigfft implements multiplication of big.Int using FFT.
The implementation is based on the Schönhage-Strassen method
using integer FFT modulo 2^n+1.
scan.goarith_amd64.s
Package-Level Type Names (total 5, none are exported)
/* sort exporteds by: | */
A fermat of length w+1 represents a number modulo 2^(w*_W) + 1. The last
word is zero or one. A number has at most two representatives satisfying the
0-1 last word constraint.
Add computes addition mod 2^n+1.
( T) Mul(x, y fermat) fermat
Shift computes (x << k) mod (2^n+1).
ShiftHalf shifts x by k/2 bits the left. Shifting by 1/2 bit
is multiplication by sqrt(2) mod 2^n+1 which is 2^(3n/4) - 2^(n/4).
A temporary buffer must be provided in tmp.
( T) String() string
Sub computes substraction mod 2^n+1.
( T) norm()
T : fmt.Stringer
T : context.stringer
T : os/signal.stringer
T : runtime.stringer
func basicMul(z, x, y fermat)
func fourier(dst []fermat, src []fermat, backward bool, n int, k uint)
func fourier(dst []fermat, src []fermat, backward bool, n int, k uint)
A polValues represents the value of a poly at the powers of a
K-th root of unity θ=2^(l/2) in Z/(b^n+1)Z, where b^n = 2^(K/4*l).
// k is such that K = 1<<k.
// the length of coefficients, n*_W a multiple of K/4.
// a slice of K (n+1)-word values
InvTransform reconstructs a polynomial from its values at
roots of x^K+1. The m field of the returned polynomial
is unspecified.
InvTransform reconstructs p (modulo X^K - 1) from its
values at θ^i for i = 0..K-1.
Mul returns the pointwise product of p and q.
poly represents an integer via a polynomial in Z[x]/(x^K+1)
where K is the FFT length and b^m is the computation basis 1<<(m*_W).
If P = a[0] + a[1] x + ... a[n] x^(K-1), the associated natural number
is P(b^m).
// a slice of at most K m-word coefficients.
// k is such that K = 1<<k.
// the m such that P(b^m) is the original number.
Int evaluates back a poly to its integer value.
Mul multiplies p and q modulo X^K-1, where K = 1<<p.k.
The product is done via a Fourier transform.
NTransform evaluates p at θω^i for i = 0...K-1, where
θ is a (2K)-th primitive root of unity in Z/(b^n+1)Z
and ω = θ².
Transform evaluates p at θ^i for i = 0...K-1, where
θ is a K-th primitive root of unity in Z/(b^n+1)Z.
func polyFromNat(x nat, k uint, m int) poly
Package-Level Functions (total 17, in which 2 are exported)
FromDecimalString converts the base 10 string
representation of a natural (non-negative) number
into a *big.Int.
Its asymptotic complexity is less than quadratic.
Mul computes the product x*y and returns z.
It can be used instead of the Mul method of
*big.Int from math/big package.
valueSize returns the length (in words) to use for polynomial
coefficients, to compute a correct product of polynomials P*Q
where deg(P*Q) < K (== 1<<k) and where coefficients of P and Q are
less than b^m (== 1 << (m*_W)).
The chosen length (in bits) must be a multiple of 1 << (k-extra).
Package-Level Variables (total 2, neither is exported)
fftSizeThreshold[i] is the maximal size (in bits) where we should use
fft size i.
fftThreshold is the size (in words) above which FFT is used over
Karatsuba from math/big.
TestCalibrate seems to indicate a threshold of 60kbits on 32-bit
arches and 110kbits on 64-bit arches.
Package-Level Constants (total 2, neither is exported)
quadraticScanThreshold is the number of digits
below which big.Int.SetString is more efficient
than subquadratic algorithms.
1232 digits fit in 4096 bits.
The pages are generated with Goldsv0.3.6. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.