Irrational base discrete weighted transform

Last updated

In mathematics, the irrational base discrete weighted transform (IBDWT) is a variant of the fast Fourier transform using an irrational base; it was developed by Richard Crandall (Reed College), Barry Fagin (Dartmouth College) and Joshua Doenias (NeXT Software) [1] in the early 1990s using Mathematica. It implies a fast, practical implementation of large-number modular multiplication on modern computers, at asymptotically 2× faster than non-modular FFT multiplication. [2] [3]

Contents

It is most notably used in the Great Internet Mersenne Prime Search.

Algorithm

The IBDWT method, as applied to the Lucas-Lehmer test for Mersenne primes (which requires repeated squaring modulo a Mersenne number ), is based on four key elements developed by Crandall and Fagin: [4]

This approach avoids the need for zero-padding the arrays and performs the multiplication modulo directly. [4] The algorithm to compute the product is as follows: [4]

  1. Choose a run length (signal-length) . [4]
  2. Establish a variable base representation for the numbers. For example, . [4] Each term is usually between 16 and 20 bits if using double-precision terms.
  3. Define a weight-signal where each component , approximated by floats in the interval [1, 2). [4]
  4. Compute the forward DWT for both numbers: and . This is practically computed using a standard DFT (like an FFT) as . [4]
  5. Perform a component-wise product of the transformed arrays: . [4]
  6. Compute the inverse DWT: . This is computed as . [4]
  7. Round the resulting components to the nearest integer: , optionally checking the roundoff error is no greater than 0.4 (greater indicates too many integer bits stuffed into each term). [4]
  8. Adjust the resulting digits to restore the variable-base radix representation. This step handles carries and borrows. Single-step partial carrying is sufficient. [4]

Applications

Double-precision IBDWT is used in the Great Internet Mersenne Prime Search's x86 client Prime95 to perform modular multiplication in the Lucas–Lehmer test and Fermat primarily tests. The prime95 IBDWT library gwnum is also used in programs such as PrimeGrid's LLR2 and PRST. It is chosen because x86 CPUs since Pentium 4 have so much double-precision floating-point computing power that it is much faster to multiply numbers using IBDWT than to do the so using a more straightforward integer FFT (NTT).

Double-precision IBDWT has also been ported to other CPU architectures in the form of Glucas. It has also been ported to GPUs in the form of CUDALucas, GPUowl, and PRPLL. [4]

IBDWT can also be done using integer arithmetic modulo 264-232+1, a number theoretic transform. This approach was first demonstrated by Nick Craig-Wood in ARMPrime. [5] This too has been ported to GPUs, providing an alternative for consumer GPUs with weak double-precision computing power but acceptable 32-bit integer power, especially Nvidia models from the 2020s boasting "1:1" or "1:2" 32-bit integer multiplication speed but "1:64" double-precision speed relative to 32-bit floating-point. [6]

Derived methods

Granger and Scott demonstrated using IBDWT-inspired "GRP (generalized repunit prime) multiplication" to accelerate eliptic curve cryptography over F(2521-1), the P-521. This is a Karatsuba-like technique featuring a cyclic convolution similar to IBDWT. [3]

References

  1. Crandall, Richard (1997). "The Challenge of Large Numbers" . Scientific American. 276 (2): 74–78. Bibcode:1997SciAm.276b..74C. doi:10.1038/scientificamerican0297-74. JSTOR   24993611 . Retrieved 29 March 2023.
  2. "Mathematica Use of Renowned Computational Scientist and Author Richard Crandall". Wolfram Research. Retrieved 29 March 2023.
  3. 1 2
  4. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Thall, Andrew. "Fast Mersenne Prime Testing on the GPU" (PDF). Retrieved 29 March 2023.
  5. Craig-Wood, Nick (4 October 2023). "ncw/iprime". GitHub .
  6. Gallot, Yves (21 September 2025). "galloty/marin". GitHub .