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.

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

9.6.1 Polynomial multiplication<br />

We have seen that polynomial multiplication is equivalent to acyclic<br />

convolution. Therefore, the product of two polynomials can be effected via<br />

a cyclic and a negacyclic. One simply constructs respective signals having the<br />

polynomial coefficients, and invokes Theorem 9.5.10. An alternative is simply<br />

to zero-pad the signals to twice their lengths and perform a single cyclic (or<br />

single negacyclic).<br />

But there exist interesting—and often quite efficient—means of multiplying<br />

polynomials if one has a general integer multiply algorithm. The method<br />

amounts to placing polynomial coefficients strategically within certain large<br />

integers, and doing all the arithmetic with one high-precision integer multiply.<br />

We give the algorithm for the case that all polynomial coefficients are nonnegative,<br />

although this constraint is irrelevant for multiplication in polynomial<br />

rings (mod p):<br />

Algorithm 9.6.1 (Fast polynomial multiplication: Binary segmentation).<br />

Given two polynomials x(t) = D−1 j=0 xjtj and y(t) = E−1 k=0 yktk with all coefficients<br />

integral and nonnegative, this algorithm returns the polynomial product<br />

z(t) =x(t)y(t) in the form of a signal having the coefficients of z.<br />

1. [Initialize]<br />

Choose b such that 2 b > max{D, E} max{xj} max{yk};<br />

2. [Create binary segmentation integers]<br />

X = x 2 b ;<br />

Y = y 2 b ;<br />

// These X, Y can be constructed by arranging a binary array of<br />

sufficiently many 0’s, then writing in the bits of each coefficient,<br />

justified appropriately.<br />

3. [Multiply]<br />

u = XY ; // Integer multiplication.<br />

4. [Reassemble coefficients into signal]<br />

for(0 ≤ l

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

Saved successfully!

Ooh no, something went wrong!