10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.5 Large-integer multiplication 481<br />

while(k ≤ j) {<br />

j = j − k;<br />

k = ⌊k/2⌋;<br />

}<br />

j = j + k;<br />

}<br />

return;<br />

}<br />

It is to be noted that when one performs a convolution in the manner we shall<br />

exhibit later, the scrambling procedures are not needed, provided that one<br />

performs required FFTs in a specific order.<br />

Correct is Gentleman–Sande form (with scrambling procedure omitted)<br />

first, Cooley–Tukey form (without initial scrambling) second. This works out<br />

because, of course, scrambling is an operation of order two.<br />

Happily, in cases where scrambling is not desired, or when contiguous<br />

memory access is important (e.g., on vector computers), there is the Stockham<br />

FFT, which avoids bit-scrambling and also has an innermost loop that runs<br />

essentially consecutively through data memory. The cost of all this is that<br />

one must use an extra copy of the data. The typical implementations of<br />

the Stockham FFT are elegant [Van Loan 1992], but there is a particular<br />

variant that has proved quite useful on modern vector machinery. This special<br />

variant is the “ping-pong” FFT, because one goes back and forth between the<br />

original data and a separate copy. The following algorithm display is based<br />

on a suggested design of [Papadopoulos 1999]:<br />

Algorithm 9.5.6 (FFT, “ping-pong” variant, in-order, no bit-scramble).<br />

Given a (D =2 d )-element signal x, a Stockham FFT is performed, but with<br />

the original x and external data copy y used in alternating fashion. We interpret<br />

X, Y below as pointers to the (complex) signals x, y, respectively, but operating<br />

under the usual rules of pointer arithmetic; e.g., X[0] is the first complex datum<br />

of x initially, but if 4 is added to pointer X, thenX[0] = x4, andsoon.If<br />

exponent d is even, pointer X has the FFT result, else pointer Y has it.<br />

1. [Initialize]<br />

J =1;<br />

X = x; Y = y; // Assign memory pointers.<br />

2. [Outer loop]<br />

for(d ≥ i>0) {<br />

m =0;<br />

while(m 0) {<br />

Y [0] = X[0] + X[D/2];<br />

Y [J] =a(X[0] − X[D/2]);<br />

X = X +1;<br />

Y = Y +1;

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

Saved successfully!

Ooh no, something went wrong!