integer multiplication with generalized fermat primes
play

Integer multiplication with generalized Fermat primes Svyatoslav - PowerPoint PPT Presentation

Integer multiplication with generalized Fermat primes Svyatoslav Covanov CARAMEL Team, LORIA, University of Lorraine Supervised by: Emmanuel Thom and Jrmie Detrey Journes nationales du Calcul Formel 2015 (Cluny) November 4, 2015


  1. Integer multiplication with generalized Fermat primes Svyatoslav Covanov CARAMEL Team, LORIA, University of Lorraine Supervised by: Emmanuel Thomé and Jérémie Detrey Journées nationales du Calcul Formel 2015 (Cluny) November 4, 2015

  2. Summary Using generalized Fermat 3 Fast Fourier Transform 1 primes Naive multiplication Number-theoretic Multiplying integer transform using polynomials A Fürer-like number FFT theoretic transform Schönhage-Strassen Comparison of Some remarks complexities Fürer 2 Factorization of FFT A new ring and a new cut Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 2 / 23

  3. Fast Fourier Transform Using generalized Fermat 3 Fast Fourier Transform 1 primes Naive multiplication Number-theoretic Multiplying integer transform using polynomials A Fürer-like number FFT theoretic transform Schönhage-Strassen Comparison of Some remarks complexities Fürer 2 Factorization of FFT A new ring and a new cut Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 3 / 23

  4. Fast Fourier Transform Naive multiplication How to multiply two numbers a = ( a 0 · · · a N ) and b = ( b 0 · · · b N ) where a and b are given in binary representation? Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 4 / 23

  5. Fast Fourier Transform Naive multiplication How to multiply two numbers a = ( a 0 · · · a N ) and b = ( b 0 · · · b N ) where a and b are given in binary representation? First idea: Sum all a i ∗ b using 2-shift. This method has a O ( N 2 ) bit complexity. Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 4 / 23

  6. Fast Fourier Transform Naive multiplication How to multiply two numbers a = ( a 0 · · · a N ) and b = ( b 0 · · · b N ) where a and b are given in binary representation? First idea: Sum all a i ∗ b using 2-shift. This method has a O ( N 2 ) bit complexity. People believed long enough it was the best complexity we could reach (Kolmogorov). Karatsuba proved that it was wrong... Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 4 / 23

  7. Fast Fourier Transform Multiplying integer using polynomials The fastest known algorithm is based on the evaluation-interpolation paradigm. Input: 2 numbers a and b of N bits. i a i x i and We decompose the input into 2 polynomials A = � i b i x i (deg A = deg B = n , | a i | = | b i | = N / ( 2 n ) = k , and B = � a i = b i = 0 for i > n ). A ( 2 k ) = a 0 + 2 k × a 1 + · · · + a 2 n − 1 × 2 ( 2 n − 1 ) k = a B ( 2 k ) = b 0 + 2 k × b 1 + · · · + b 2 n − 1 × 2 ( 2 n − 1 ) k = b Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 5 / 23

  8. Fast Fourier Transform Multiplying integer using polynomials The fastest known algorithm is based on the evaluation-interpolation paradigm. Input: 2 numbers a and b of N bits. i a i x i and We decompose the input into 2 polynomials A = � i b i x i (deg A = deg B = n , | a i | = | b i | = N / ( 2 n ) = k , and B = � a i = b i = 0 for i > n ). A ( 2 k ) = a 0 + 2 k × a 1 + · · · + a 2 n − 1 × 2 ( 2 n − 1 ) k = a B ( 2 k ) = b 0 + 2 k × b 1 + · · · + b 2 n − 1 × 2 ( 2 n − 1 ) k = b We work in some ring R in which we have a 2 n -th principal root of unity ω . Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 5 / 23

  9. Fast Fourier Transform Multiplying integer using polynomials The fastest known algorithm is based on the evaluation-interpolation paradigm. Input: 2 numbers a and b of N bits. i a i x i and We decompose the input into 2 polynomials A = � i b i x i (deg A = deg B = n , | a i | = | b i | = N / ( 2 n ) = k , and B = � a i = b i = 0 for i > n ). A ( 2 k ) = a 0 + 2 k × a 1 + · · · + a 2 n − 1 × 2 ( 2 n − 1 ) k = a B ( 2 k ) = b 0 + 2 k × b 1 + · · · + b 2 n − 1 × 2 ( 2 n − 1 ) k = b We work in some ring R in which we have a 2 n -th principal root of unity ω . We compute the A ( ω i ) and B ( ω i ) . Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 5 / 23

  10. Fast Fourier Transform Multiplying integer using polynomials The fastest known algorithm is based on the evaluation-interpolation paradigm. Input: 2 numbers a and b of N bits. i a i x i and We decompose the input into 2 polynomials A = � i b i x i (deg A = deg B = n , | a i | = | b i | = N / ( 2 n ) = k , and B = � a i = b i = 0 for i > n ). A ( 2 k ) = a 0 + 2 k × a 1 + · · · + a 2 n − 1 × 2 ( 2 n − 1 ) k = a B ( 2 k ) = b 0 + 2 k × b 1 + · · · + b 2 n − 1 × 2 ( 2 n − 1 ) k = b We work in some ring R in which we have a 2 n -th principal root of unity ω . We compute the A ( ω i ) and B ( ω i ) . We recover A · B from the points A ( ω i ) · B ( ω i ) with Lagrange interpolation for a polynomial of degree 2 n − 1. Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 5 / 23

  11. Fast Fourier Transform Multiplying integer using polynomials The fastest known algorithm is based on the evaluation-interpolation paradigm. Input: 2 numbers a and b of N bits. i a i x i and We decompose the input into 2 polynomials A = � i b i x i (deg A = deg B = n , | a i | = | b i | = N / ( 2 n ) = k , and B = � a i = b i = 0 for i > n ). A ( 2 k ) = a 0 + 2 k × a 1 + · · · + a 2 n − 1 × 2 ( 2 n − 1 ) k = a B ( 2 k ) = b 0 + 2 k × b 1 + · · · + b 2 n − 1 × 2 ( 2 n − 1 ) k = b We work in some ring R in which we have a 2 n -th principal root of unity ω . We compute the A ( ω i ) and B ( ω i ) . We recover A · B from the points A ( ω i ) · B ( ω i ) with Lagrange interpolation for a polynomial of degree 2 n − 1. The DFT algorithm allows one to compute the A ( ω i ) and B ( ω i ) . Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 5 / 23

  12. Fast Fourier Transform Multiplying integer using polynomials [ a 0 , . . . , a 2 n − 1 ] [ b 0 , . . . , b 2 n − 1 ] DFT DFT [ x 0 , . . . , x 2 n − 1 ] [ y 0 , . . . , y 2 n − 1 ] Component Multiply [ x 0 y 0 , . . . , x 2 n − 1 y 2 n − 1 ] inverse DFT Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 6 / 23

  13. Fast Fourier Transform FFT P is a polynomial of degree 2 n − 1 ( n is a power of 2) and ω is a 2 n -th principal root of unity in R ( C or Z / p Z for example), which j ∈ [ 0 , 2 n − 1 ] ω ij = 0 for i ∈ [ 1 , 2 n − 1 ] . means that � Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 7 / 23

  14. Fast Fourier Transform FFT P is a polynomial of degree 2 n − 1 ( n is a power of 2) and ω is a 2 n -th principal root of unity in R ( C or Z / p Z for example), which j ∈ [ 0 , 2 n − 1 ] ω ij = 0 for i ∈ [ 1 , 2 n − 1 ] . means that � FFT( P , ω , 2 n − 1) if n = 1 then return P 0 + P 1 + X ( P 0 − P 1 ) end if P even ← ( P 2 i ) i P odd ← ( P 2 i + 1 ) i Q even ← FFT( P even , ω 2 , n − 1) Q odd ← FFT( P odd , ω 2 , n − 1) Q ← Q even ( X ) + Q odd ( ω X ) + X n · ( Q odd ( X ) − Q even ( ω X )) return Q Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 7 / 23

  15. Fast Fourier Transform FFT P is a polynomial of degree 2 n − 1 ( n is a power of 2) and ω is a 2 n -th principal root of unity in R ( C or Z / p Z for example), which j ∈ [ 0 , 2 n − 1 ] ω ij = 0 for i ∈ [ 1 , 2 n − 1 ] . means that � FFT( P , ω , 2 n − 1) if n = 1 then return P 0 + P 1 + X ( P 0 − P 1 ) end if P even ← ( P 2 i ) i P odd ← ( P 2 i + 1 ) i Q even ← FFT( P even , ω 2 , n − 1) Q odd ← FFT( P odd , ω 2 , n − 1) Q ← Q even ( X ) + Q odd ( ω X ) + X n · ( Q odd ( X ) − Q even ( ω X )) return Q Complexity: O ( n log n ) operations in R , among which multiplications by some powers of ω , additions and subtractions. Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 7 / 23

  16. Fast Fourier Transform FFT ⊗ ⊗ ⊗ Q bitrev ( 0 ) P 0 ⊗ ⊗ ⊗ ω 0 Q bitrev ( 1 ) P 1 ⊗ ⊗ ω 0 ⊗ Q bitrev ( 2 ) P 2 ⊗ ⊗ ω 0 ⊗ ω 1 Q bitrev ( 3 ) P 3 ⊗ ω 0 ⊗ ⊗ Q bitrev ( 4 ) P 4 ⊗ ω 0 ⊗ ⊗ ω 2 Q bitrev ( 5 ) P 5 ⊗ ω 0 ⊗ ω 2 ⊗ Q bitrev ( 6 ) P 6 ⊗ ω 0 ⊗ ω 2 ⊗ ω 3 Q bitrev ( 7 ) P 7 ⊗ ⊗ ⊗ Q bitrev ( 8 ) P 8 ⊗ ⊗ ⊗ ω 4 Q bitrev ( 9 ) P 9 ⊗ ⊗ ω 4 ⊗ Q bitrev ( 10 ) P 10 ⊗ ⊗ ω 4 ⊗ ω 5 Q bitrev ( 11 ) P 11 ⊗ ω 4 ⊗ ⊗ Q bitrev ( 12 ) P 12 ⊗ ⊗ ⊗ ω 4 ω 6 Q bitrev ( 13 ) P 13 ⊗ ω 4 ⊗ ω 6 ⊗ Q bitrev ( 14 ) P 14 ⊗ ω 4 ⊗ ω 6 ⊗ ω 7 Q bitrev ( 15 ) P 15 Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 8 / 23

  17. Fast Fourier Transform Schönhage-Strassen 1 N : # bits of the integers that we multiply. 2 2 n : degree of the polynomials A and B used to represent a and b . 3 k : # bits used to encode the coefficients of A and B : a = A ( 2 k ) and b = B ( 2 k ) . Svyatoslav Covanov Integer multiplication with generalized Fermat primes November 4, 2015 9 / 23

Recommend


More recommend