mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Math

Reply
 
Thread Tools
Old 2004-01-03, 04:31   #12
dsouza123
 
dsouza123's Avatar
 
Sep 2002

29616 Posts
Default

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.
dsouza123 is offline   Reply With Quote
Old 2004-01-03, 07:14   #13
Cyclamen Persicum
 
Cyclamen Persicum's Avatar
 
Mar 2003

1218 Posts
Default

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!!!!!!!),
Cyclamen Persicum is offline   Reply With Quote
Old 2004-01-06, 12:12   #14
alpertron
 
alpertron's Avatar
 
Aug 2002
Buenos Aires, Argentina

25268 Posts
Default Computing inverse for Montgomery modular reduction

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.
alpertron is offline   Reply With Quote
Old 2004-03-04, 12:47   #15
Cyclamen Persicum
 
Cyclamen Persicum's Avatar
 
Mar 2003

8110 Posts
Default

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.
Here we should calculate 137 mod 73 = 64 using division again.

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
Cyclamen Persicum is offline   Reply With Quote
Old 2004-03-04, 13:44   #16
HiddenWarrior
 
HiddenWarrior's Avatar
 
Jun 2003
Russia, Novosibirsk

2×107 Posts
Default

and what about 12345678 modulo 4321 for example? What z to take?
HiddenWarrior is offline   Reply With Quote
Old 2004-03-04, 13:57   #17
Cyclamen Persicum
 
Cyclamen Persicum's Avatar
 
Mar 2003

10100012 Posts
Default

Quote:
Originally Posted by HiddenWarrior
and what about 12345678 modulo 4321 for example? What z to take?
10^5 mod 4321 = 0617

Last fiddled with by Cyclamen Persicum on 2004-03-04 at 14:05
Cyclamen Persicum is offline   Reply With Quote
Reply



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

All times are UTC. The time now is 17:43.


Fri Jul 16 17:43:35 UTC 2021 up 49 days, 15:30, 1 user, load averages: 1.70, 1.52, 1.51

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.