![]() |
|
|
#12 |
|
Sep 2002
29616 Posts |
Cyclamen, I have coded the example you gave (with the size a single 32bit longword first).
I followed most of it, the part that still baffles me is the z = - 23 ^ (-1) mod 100 = -87 = 13. Using z = -3^(-1) mod 10 gets the 7 but what about the -80 ? I have been thinking about the only need the lowest digit in the case of mod 100 for the factor 23 z = - 3 ^ (-1) mod 10 I figured it ment 10 - 3 = 7 or -3 + 10 = 7 I have tried tracing through the 2^32 nary Inverse32 code but there must be something that uses a some sort of implicit wrap around/mod 2^32 in it because I plugged in 23 and got a very large number. I have been thinking about the only need the lowest digit in the case of mod 100 for the factor 23 z = - 3 ^ (-1) mod 10 I figured it ment 10 - 3 = 7 or -3 + 10 = 7 Where you said for UNIT, full modulo not required if more that 100 - 23 = 77 is done say the full 100 mod 23 = 8 is that OK ? I do appreciate the work you put in your replies. |
|
|
|
|
|
#13 |
|
Mar 2003
1218 Posts |
Sorry, I made a little mistake =))).
The first square is not needed. Is it 2^22 mod 23 obtained? =))) I have been thinking about the only need the lowest digit in the case of mod 100 for the factor 23 z = - 3 ^ (-1) mod 10 I figured it ment 10 - 3 = 7 or -3 + 10 = 7 it means -3^(-1) mod 10 = -7 mod 10 = 3 (three!!!!!!!), |
|
|
|
|
|
#14 |
|
Aug 2002
Buenos Aires, Argentina
25268 Posts |
If the modulus is 2^32, the value x = -N^(-1) mod 2^32 (where N is odd) needed for the Montgomery algorithm can be easily found without Extended Euclidean Algorithm by:
x <- 2 - N x <- x (2 - Nx) x <- x (2 - Nx) x <- x (2 - Nx) x <- x (Nx - 2) It is assumed that all computations are done with 32-bit numbers. |
|
|
|
|
|
#15 |
|
Mar 2003
8110 Posts |
I have "discovered" a very simple method of modular reduction.
Whom is it named after? It's much easier and almost as effective as Montgomery. It is known that school-boy division requires n elementary Div operations and n^2 Mult operations. "My" method eliminates the majority of Div operations, i.e. has O(1) complexity instead O(n) relative elementary Div. Lets find a remainder: 12345678 modulo 73. First of all, calculate z=1000 mod 73=51 using ordinary division. Then do as follows: Code:
12345678
+51=z*1
2855678
+102=z*2
957678
+459
103578
+51
8678
+408
1086
+51
137 - the correct answer, but further reduction is needed.
So we need a couple elementary Div operations instead n in case of ordinary Division Last fiddled with by Cyclamen Persicum on 2004-03-04 at 12:50 |
|
|
|
|
|
#16 |
|
Jun 2003
Russia, Novosibirsk
2×107 Posts |
and what about 12345678 modulo 4321 for example? What z to take?
|
|
|
|
|
|
#17 | |
|
Mar 2003
10100012 Posts |
Quote:
Last fiddled with by Cyclamen Persicum on 2004-03-04 at 14:05 |
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A quick question | Pegos | Information & Answers | 6 | 2016-08-11 14:39 |
| Quick TF Question | Dubslow | GPU Computing | 2 | 2011-10-27 04:49 |
| Quick msieve question | alkirah | Msieve | 2 | 2009-12-30 14:00 |
| Quick & Dirty | storm5510 | Programming | 37 | 2009-09-08 06:52 |
| Quick p-1 question | Unregistered | Software | 8 | 2006-10-13 23:35 |