Prime Numbers

Prime Numbers Prime Numbers

thales.doa.fmph.uniba.sk
from thales.doa.fmph.uniba.sk More from this publisher
10.12.2012 Views

9.5 Large-integer multiplication 499 rings and fields. The primary observation is that over a ring or field, the DFT defining relations (9.20) and (9.21) need no modification whatever, as long as we understand the requisite operations to occur (legally) in the algebraic domain at hand. In particular, a number-theoretical DFT of length D supports cyclic convolution of length D, via the celebrated convolution Theorem 9.5.11, whenever both D −1 and g, a primitive D-th root of unity, exist in the algebraic domain. With these constraints in mind, number-theoretical transforms have attained a solid niche, in regard to fast algorithms in the field of digital signal processing. Not just raw convolution, but other interesting applications of such transforms can be found in the literature. A typical example is the use of number-theoretical transforms for classical algebraic operations [Yagle 1995], while yet more applications are summarized in [Madisetti and Williams 1997]. Our first example will be the case that the relevant domain is Fp. For a prime p and some divisor d|p − 1 let the field be Fp and consider the relevant transform to be Xk = (p−1)/d−1 j=0 xjh −jk mod p, (9.33) where h is an element of multiplicative order (p − 1)/d in Fp. Note that the mod operation can in principle be taken either after individual summands, or for the whole sum, or in some combination of these, so that for convenience we simply append the symbols “mod p” to indicate that a transform element Xk is to be reduced to lie in the interval [0,p−1]. Now the inverse transform is (p−1)/d−1 xj = −d Xkh jk mod p, (9.34) k=0 whose prefactor is just ((p − 1)/d) −1 mod p ≡−d. These transforms can be used to provide increased precision for convolutions. The idea is to establish each convolution element (mod pr) for some convenient set of primes {pr}, whence the exact convolution can be reconstructed using the Chinese remainder theorem. Algorithm 9.5.20 (Integer convolution on a CRT prime set). Given two signals x, y each of length N =2 m having integer elements bounded by 0 ≤ xj,yj NM2 ; for(1 ≤ r ≤ q) { Find a primitive root gr of pr; hr = gar r mod pr; // hr is an N-th root of 1. } 2. [Loop over primes]

500 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC for(1 ≤ r ≤ q) { h = hr; p = pr; d = ar; // Preparing for DFTs. X (r) = DFT(x); // Via relation (9.33). Y (r) = DFT(y); 3. [Dyadic product] Z (r) = X (r) ∗ Y (r) ; 4. [Inverse transforms] z (r) = DWT −1 (Z (r) ); // Via relation (9.34). } 5. [Reconstruct elements] From the now known relations zj ≡ z (r) j (mod pr) find each (unambiguous) element zj in [0,NM2 ) via CRT reconstruction, using such as Algorithm 2.1.7 or 9.5.26; return z; What this algorithm does is allow us to invoke length-2 m FFTs for the DFT and its inverse, except that only integer arithmetic is to be used in the usual FFT butterflies (and of course the butterflies are continually reduced (mod pr) during the FFT calculations). This scheme has been used to good effect in [Montgomery 1992a] in various factorization implementations. Note that if the forward DFT (9.33) is performed with a decimation-in-frequency (DIF) algorithm, and the reverse DFT (9.34) with a DIT algorithm, there is no need to invoke the scramble function of Algorithm 9.5.5 in either of the FFT functions shown there. A second example of useful number-theoretical transforms has been called the discrete Galois transform (DGT) [Crandall 1996a], with relevant field F p 2 for p =2 q − 1 a Mersenne prime. The delightful fact about such fields is that the multiplicative group order is |F ∗ p 2| = p2 − 1=2 q+1 (2 q−1 − 1), so that in practice, one can find primitive roots of unity of orders N =2 k as long as k ≤ q + 1. We can thus define discrete transforms of such lengths, as Xk = N−1 j=0 xjh −jk mod p, (9.35) where now all arithmetic is presumed, due to the known structure of F p 2 for primes p ≡ 3 (mod 4), to involve complex (Gaussian) integers (mod p) with N =2 k , xj =Re(xj)+i Im(xj), h =Re(h)+i Im(h), the latter being an element of multiplicative order N in F p 2, with the transform element Xk itself being a Gaussian integer (mod p). Happily, there

500 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC<br />

for(1 ≤ r ≤ q) {<br />

h = hr; p = pr; d = ar; // Preparing for DFTs.<br />

X (r) = DFT(x); // Via relation (9.33).<br />

Y (r) = DFT(y);<br />

3. [Dyadic product]<br />

Z (r) = X (r) ∗ Y (r) ;<br />

4. [Inverse transforms]<br />

z (r) = DWT −1 (Z (r) ); // Via relation (9.34).<br />

}<br />

5. [Reconstruct elements]<br />

From the now known relations zj ≡ z (r)<br />

j (mod pr) find each (unambiguous)<br />

element zj in [0,NM2 ) via CRT reconstruction, using such as Algorithm<br />

2.1.7 or 9.5.26;<br />

return z;<br />

What this algorithm does is allow us to invoke length-2 m FFTs for the DFT<br />

and its inverse, except that only integer arithmetic is to be used in the usual<br />

FFT butterflies (and of course the butterflies are continually reduced (mod pr)<br />

during the FFT calculations). This scheme has been used to good effect in<br />

[Montgomery 1992a] in various factorization implementations. Note that if<br />

the forward DFT (9.33) is performed with a decimation-in-frequency (DIF)<br />

algorithm, and the reverse DFT (9.34) with a DIT algorithm, there is no<br />

need to invoke the scramble function of Algorithm 9.5.5 in either of the FFT<br />

functions shown there.<br />

A second example of useful number-theoretical transforms has been called<br />

the discrete Galois transform (DGT) [Crandall 1996a], with relevant field F p 2<br />

for p =2 q − 1 a Mersenne prime. The delightful fact about such fields is that<br />

the multiplicative group order is<br />

|F ∗ p 2| = p2 − 1=2 q+1 (2 q−1 − 1),<br />

so that in practice, one can find primitive roots of unity of orders N =2 k as<br />

long as k ≤ q + 1. We can thus define discrete transforms of such lengths, as<br />

Xk =<br />

N−1 <br />

j=0<br />

xjh −jk mod p, (9.35)<br />

where now all arithmetic is presumed, due to the known structure of F p 2 for<br />

primes p ≡ 3 (mod 4), to involve complex (Gaussian) integers (mod p) with<br />

N =2 k ,<br />

xj =Re(xj)+i Im(xj),<br />

h =Re(h)+i Im(h),<br />

the latter being an element of multiplicative order N in F p 2, with the<br />

transform element Xk itself being a Gaussian integer (mod p). Happily, there

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!