Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 The Accelerated Integer GCD Algorithm KENNETH WEBER Kent State University ACM Transactions on Mathematical Software 張圻毓.

Similar presentations


Presentation on theme: "1 The Accelerated Integer GCD Algorithm KENNETH WEBER Kent State University ACM Transactions on Mathematical Software 張圻毓."— Presentation transcript:

1 1 The Accelerated Integer GCD Algorithm KENNETH WEBER Kent State University ACM Transactions on Mathematical Software 張圻毓

2 2 Outline Main algorithm Dmod operation General ReducedRatMod algorithm Example

3 3 Main algorithm Input: u o, v o >0, with l β (u o ) ≧ l β (v o ) and gcd(u o,β)=gcd(v o,β) = 1 Output: gcd(u o, v o ) u=u 0, v=v 0 while v ≠ 0 do if l β (u) - l β (v) > s(v) then u = dmod(u, v,β) else (n, d) = ReducedRatMod(u, v, β 2t(v) ) u = |nv – dul|/ β 2t(v) RemoveFactors(u,β) swap(u,v) x = gcd(dmod(v o, u, β), u) return gcd(dmod(u o, x, β), x)

4 4 Dmod operation The dmod ( “ digit modulus ” ) operation is defined as

5 5 Dmod operation Input: u o, v o,β >0, with gcd(v o,β) = 1 Output: |u 0 -(u 0 /v 0 mod β lβ(u0)-lβ(v0)+1 )v 0 |/β lβ(u0)-lβ(v0)+1 u = u o while l β (u) ≧ l β (v 0 ) + W do if u ≠ 0 (mod β w ) then u = |u – (u/v 0 mod β w )v o | u = u/β w d = l β (u) - l β (v 0 ) if u ≠ 0 (modβ d+1 ) then u = |u – (u/v 0 mod β d+1 )v o | return u/β d+1

6 6 General ReducedRatMod algorithm Input:.x, y>0, m > 1 with gcd(x,m)=gcd(y, m)= 1 Output: (n, d) such that 0 < n, |d|< √m and ny=xd (mod m) c = x/y mod m f 1 =(n 1,d 1 )=(m,0) f 2 =(n 2,d 2 )=(c,1) while n 2 ≧ √m f 1 = f 1 - └ n 1 /n 2┘ f 2 swap(f 1,f 2 ) return f 2

7 7 Example u=243 v=231 m=64 C=243/231 mod 64 f 1 =(n 1,d 1 )=(m,0)=(64,0) f 2 =(n 2,d 2 )=(c,1)=(21,1) f 1 =(21,1) f 2 =(1,-3) u =|1*231-(-3)*243| /64 = 15

8 8 Example u=231 v=15 m=64 C=231/15 mod 64 f 1 =(n 1,d 1 )=(m,0)=(64,0) f 2 =(n 2,d 2 )=(c,1)=(23,1) f 1 =(23,1) f 2 =(18,-2) f 1 =(18,-2) f 2 =(5,3) u =|5*15-3*231| /64 = 12

9 9 Example99 u=15 v=12/4=3 m=64 C=15/3 mod 64 f 1 =(n 1,d 1 )=(m,0)=(64,0) f 2 =(n 2,d 2 )=(c,1)=(59,1) f 1 =(59,1) f 2 =(5,-1) u =|5*12+1*15| /64 = < 64


Download ppt "1 The Accelerated Integer GCD Algorithm KENNETH WEBER Kent State University ACM Transactions on Mathematical Software 張圻毓."

Similar presentations


Ads by Google