A Generalization of the Binary GCD Algorithm - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

A Generalization of the Binary GCD Algorithm

Description:

set c = (a*b-1) mod 2d. then C= (A-c*B)/2d is d bits shorter than A. The ... This method for computing b/a requires only O(log2k) bit operations, and so over ... – PowerPoint PPT presentation

Number of Views:113
Avg rating:3.0/5.0
Slides: 14
Provided by: woods9
Category:

less

Transcript and Presenter's Notes

Title: A Generalization of the Binary GCD Algorithm


1
A Generalization of the Binary GCD Algorithm
  • ???

2
Outline
  • The new algorithm
  • Left shift GCD
  • How are the a and b values found?
  • Sequential Complexity
  • Question

3
The new algorithm(1)
  • CXAyB/22m
  • Let be d length(A)-length(B) and a,b
  • the trailing d bits of A,B
  • set c (ab-1) mod 2d
  • then C (A-cB)/2d is d bits shorter than A

4
The new algorithm(1)
  • GCD(A,B)GCD(B , xAyB)
  • GCD(A,B)GCD(G,A,B)
  • GCD(GCD(G,A mod G),B mod G))
  • Let x x1ßX0
  • X-1 mod ß2 ((( 1-x x)x)x)
  • modß2
  • where x x0-1 mod ß

5
The left-shift Binary
  • 1.if ultv then swap(u,v)
  • 2.while v?0 do
  • 3. compute t2ev such that t?ult2t
  • 4. uminu-t,2t-u
  • 5. if ultv then swap(u,v)
  • 6.return(u)
  • ???
  • 1.gcd(u,v)gcd(ubv,v),while b is any interger
  • 2.gcd(u,0)u

6
The left-shift k-ary GCD
  • 1.if ultv then swap(u,v)
  • 2.while v?0 do
  • 3. compute tkev such that t?u?kt
  • 4. find a,b?k such that t/ub/a
  • uat-bu
  • 5. if ultv then swap(u,v)

7
The left-shift k-ary GCD
  • Theorem
  • Let k be a positive integer. For every real
    number x 0,1, there exist integers a and b
    satisfying 0lta?k and gcd(a,b)1 such that

8
How are the a and b values found?
  • For each fraction of the form i/k2,where is an
    integer between zero and k2 , position i will
    hold an approximation b/a such that i/k2 - b/a
    ? 1 / (a( k1 ))
  • Ex. t/u 0.305
  • i?k2 0.305 1/2?5
  • so aA53, bB51

9
How are the a and b values found?
10
Sequential Complexity
  • 1. n?m. Multiplication or division of n-bit
    integers by m-bit integers can be done in O(n)
    time using precomputed tables of size at most
    O(m22m) bits.

11
Sequential Complexity
  • 2.u and v be integer of length n in binary and
    assume that a list of primes up to B is
    available.Using trial division,all common prime
    divisors ?B of u and v can be found and removed
    using tables of at most O(B) entries in time
    O(n2/logB n(B/logB)BlogB).

12
Sequential Complexity
  • 3.u and v be the inputs to the left-shift k-ary
    GCD ,n be the sum of the lengths of u and v in
    binary.If kO(n/log1.5n),then takes at most
    O(n2/logk)bit operations.
  • The total cost is O(n2/logkk2log2knk/logkklogk)
  • O(n2/logk)

13
Question
  • One of the referees pointed out that a similar
    algorithm exists for removing the precomputation
    phase from the left-shift k-ary algorithm .
  • The idea is to run Euclids algorithm on the
    input pair (i,k2) to generate a sequence of
    continuants pn/qn,where the qn increase and
    gcd(pn,qn)1

14
Question
  • Since i/k2-pn/qn 1/(qnqn1),one simply stops
    the algorithm when qn1gtk and uses pn/qn for b/a
  • This method for computing b/a requires only
    O(log2k) bit operations, and so over the course
    of the algorithm this takes only O(nlogk) times
Write a Comment
User Comments (0)
About PowerShow.com