Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Exponentiation by squaring
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Sliding-window method== This method is an efficient variant of the 2<sup>''k''</sup>-ary method. For example, to calculate the exponent 398, which has binary expansion (110 001 110)<sub>2</sub>, we take a window of length 3 using the 2<sup>''k''</sup>-ary method algorithm and calculate 1, x<sup>3</sup>, x<sup>6</sup>, x<sup>12</sup>, x<sup>24</sup>, x<sup>48</sup>, x<sup>49</sup>, x<sup>98</sup>, x<sup>99</sup>, x<sup>198</sup>, x<sup>199</sup>, x<sup>398</sup>. But, we can also compute 1, x<sup>3</sup>, x<sup>6</sup>, x<sup>12</sup>, x<sup>24</sup>, x<sup>48</sup>, x<sup>96</sup>, x<sup>192</sup>, x<sup>199</sup>, x<sup>398</sup>, which saves one multiplication and amounts to evaluating (110 001 110)<sub>2</sub> Here is the general algorithm: Algorithm: ;Input: An element ''x'' of ''G'', a non negative integer {{math|1=''n''=(''n''<sub>''l''β1</sub>, ''n''<sub>''l''β2</sub>, ..., ''n''<sub>0</sub>)<sub>2</sub>}}, a parameter ''k'' > 0 and the pre-computed values <math>x^3, x^5, ... ,x^{2^k-1}</math>. ;Output: The element ''x<sup>n</sup>'' ∈ ''G''. Algorithm: y := 1; i := l - 1 '''while''' i > -1 '''do''' '''if''' n<sub>i</sub> = 0 '''then''' y := y<sup>2</sup> i := i - 1 '''else''' s := max{i - k + 1, 0} '''while''' n<sub>s</sub> = 0 '''do''' s := s + 1<ref group="notes">In this line, the loop finds the longest string of length less than or equal to ''k'' ending in a non-zero value. Not all odd powers of 2 up to <math>x^{2^k-1}</math> need be computed, and only those specifically involved in the computation need be considered.</ref> '''for''' h := 1 '''to''' i - s + 1 '''do''' y := y<sup>2</sup> u := (n<sub>i</sub>, n<sub>i-1</sub>, ..., n<sub>s</sub>)<sub>2</sub> y := y * x<sup>u</sup> i := s - 1 '''return''' y
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Exponentiation by squaring
(section)
Add topic