![]() |
![]() |
#1 |
Apr 2014
Marlow, UK
23·7 Posts |
![]()
I have a large fixed n (around 100,000 digits, say) and need to calculate (n mod m) for many different values of m, which are smaller (tens of digits). Is there is any preconditioning I can use, or any transformations that might be applied to speed this process up at all?
|
![]() |
![]() |
![]() |
#2 |
Dec 2014
3·5·17 Posts |
![]()
Sometimes it helps to multiply all the modulo together (M) and compute
X = n mod M then x[i] = X mod m[i] is easier. But your m[i] sound too big for this to help. |
![]() |
![]() |
![]() |
#3 |
Tribal Bullet
Oct 2004
DD916 Posts |
![]()
The recursive version of the above is a 'remainder tree', and is indeed a good idea. If the product of the m's far exceeds the size of n you can do the remainder tree tree a block of m's at a time, possibly combined with the fast small-m modulo operation described here.
|
![]() |
![]() |
![]() |
#4 |
Apr 2014
Marlow, UK
23·7 Posts |
![]()
Thanks guys - will definitely investigate this approach.
|
![]() |
![]() |
![]() |
#5 |
Apr 2014
Marlow, UK
5610 Posts |
![]()
Hi Jason, do you have a reference for the Remainder Tree approach?
|
![]() |
![]() |
![]() |
#6 | |
Aug 2006
3×1,993 Posts |
![]() Quote:
https://cr.yp.to/arith/scaledmod-20040820.pdf |
|
![]() |
![]() |
![]() |
#7 | |
Apr 2014
Marlow, UK
708 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#8 |
Tribal Bullet
Oct 2004
5×709 Posts |
![]()
Bernstein's paper is probably the best theoretical reference; remainder trees are only one of the algorithms it describes.
Msieve's NFS line sieve uses remainder-tree-based batch factoring to handle the factorization of huge numbers of relatively small integers, and this lets the sieve use three large primes without the traditional overhead of doing so (code here). |
![]() |
![]() |
![]() |
#9 |
Apr 2014
Marlow, UK
23×7 Posts |
![]() |
![]() |
![]() |
![]() |
#10 |
Tribal Bullet
Oct 2004
5×709 Posts |
![]()
It does not and I have not.
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Widely varying LL test speeds after reboot | TrellisCross | Information & Answers | 3 | 2016-11-14 14:22 |
Speeding up 321 | diep | Math | 8 | 2012-12-04 15:32 |
Speeding up Mersenne hunting | m_f_h | Math | 8 | 2007-05-18 13:49 |
Benchmarks varying FSB, Memory Latency and multiplier | S485122 | Software | 0 | 2006-11-08 20:21 |
Speeding up ECM 10x | clowns789 | Software | 2 | 2004-08-11 03:45 |