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!
==Signed-digit recoding== In certain computations it may be more efficient to allow negative coefficients and hence use the inverse of the base, provided inversion in {{mvar|'''G'''}} is "fast" or has been precomputed. For example, when computing {{math|''x''<sup>2<sup>''k''</sup>β1</sup>}}, the binary method requires {{math|''k''β1}} multiplications and {{math|''k''β1}} squarings. However, one could perform {{mvar|k}} squarings to get {{math|''x''<sup>2<sup>''k''</sup></sup>}} and then multiply by {{math|''x''<sup>β1</sup>}} to obtain {{math|''x''<sup>2<sup>''k''</sup>β1</sup>}}. To this end we define the [[signed-digit representation]] of an integer {{mvar|n}} in radix {{mvar|b}} as : <math>n = \sum_{i=0}^{l-1} n_i b^i \text{ with } |n_i| < b.</math> ''Signed binary representation'' corresponds to the particular choice {{math|1=''b'' = 2}} and <math>n_i \in \{-1, 0, 1\}</math>. It is denoted by <math>(n_{l-1} \dots n_0)_s</math>. There are several methods for computing this representation. The representation is not unique. For example, take {{math|1=''n'' = 478}}: two distinct signed-binary representations are given by <math>(10\bar 1 1100\bar 1 10)_s</math> and <math>(100\bar 1 1000\bar 1 0)_s</math>, where <math>\bar 1</math> is used to denote {{math|β1}}. Since the binary method computes a multiplication for every non-zero entry in the base-2 representation of {{mvar|n}}, we are interested in finding the signed-binary representation with the smallest number of non-zero entries, that is, the one with ''minimal'' [[Hamming weight]]. One method of doing this is to compute the representation in [[non-adjacent form]], or NAF for short, which is one that satisfies <math>n_i n_{i+1} = 0 \text{ for all } i \geqslant 0</math> and denoted by <math>(n_{l-1} \dots n_0)_\text{NAF}</math>. For example, the NAF representation of 478 is <math>(1000\bar 1 000\bar 1 0)_\text{NAF}</math>. This representation always has minimal Hamming weight. A simple algorithm to compute the NAF representation of a given integer <math>n = (n_l n_{l-1} \dots n_0)_2</math> with <math>n_l = n_{l-1} = 0</math> is the following: {{nowrap|<math>c_0=0</math>}} for {{math|1=''i'' = 0}} to {{math|''l'' β 1}} do {{nowrap|<math>c_{i+1} = \left\lfloor\frac{1}{2}(c_i + n_i + n_{i+1})\right\rfloor</math>}} {{nowrap|<math>n_i' = c_i + n_i - 2c_{i+1}</math>}} {{nowrap|return <math>(n_{l-1}' \dots n_0')_\text{NAF}</math>}} Another algorithm by Koyama and Tsuruoka does not require the condition that <math>n_i = n_{i+1} = 0</math>; it still minimizes the Hamming weight.
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