mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Riesel Prime Search (https://www.mersenneforum.org/forumdisplay.php?f=59)
-   -   some tools for weights computing... (https://www.mersenneforum.org/showthread.php?t=7213)

Thomas11 2007-02-27 19:04

some tools for weights computing...
 
1 Attachment(s)
I was asked about the tools I'm using to compute the Nash weights for the larger k.
Since there might be some general interest, I'm uploading them into this thread, in hope that you find them useful. Thanks to MinGW I was able to prepare some Windows binaries too (since you're all Windoozers, right?).

You should note, that those tools where originally written for my personal use -- so there is no detailed information about the algorithms in the code, nor is there any help file etc...
Also note, that it's all about Riesel-ks, e.g. k*2^n-1. For the Proth-ks one has to modify the source code.

For general information related to the Nash weights you may also have a look into the [URL="http://www.mersenneforum.org/showthread.php?t=2645"]15k forum[/URL], where I already posted a Linux binary of the nash weight calculator.

The first tool (attached to this post) calculates the Nash weight for a single k. It should work for any k of arbitrary length.

Usage is:
[CODE]nash <k>[/CODE]
for example:
[CODE]nash 12345
12345 2060 2064
[/CODE]
The output is of the form [B]<k> <w> <w'>[/B].
The difference between [I]standard Nash weight (w)[/I] and [I]modified Nash weight (w')[/I] is that the standard Nash weight is computed for n=100001-110000, while the modified Nash weight is for n=1-10000. The latter is related to the [I]Proth weight[/I]:
[CODE]Proth weight = w' / 1751.542[/CODE]

Due to the limitation of only one attachment per posting, I will post the other stuff in the following separate posts...

Thomas11 2007-02-27 19:09

1 Attachment(s)
The next one is a multiple-k Nash calculator. Note that the current version is restricted to k<2^64 (e.g [I]unsigned long[/I])

Usage is:
[CODE]mnash <kmin> <kmax> <kstep>[/CODE]
for example:
[CODE]mnash 1 10 2
1 925 1176
3 2976 2933
5 2180 2176
7 912 917
9 1674 1678
[/CODE]

(This is the same as the older "nash3" in the 15k forum.)

Thomas11 2007-02-27 19:33

1 Attachment(s)
The final one is a bit different.
Since the Nash algorithm is quite slow when computing large ranges (e.g. millions) of k, one needs a faster tool. Therefore I implemented an ordinary sieve for p up to 512 and a smaller n range of only 1-1000. Due to precomputation of the "reversed orders of n" the whole calculation can be done in cache memory and is therefore really fast (e.g. about 3000 k/sec on a 1.7 GHz P4).

So one can use [B]multi5[/B] for a fast pre-scanning of a k-range and then do some sorting on the results and run the "good ones" through [B]nash[/B].

For some historic reason it is written in Fortran (and lacks any comments) and there are no command line options. Therefore you need to edit the [I]steer.txt[/I] file for specifying the k-range and a print condition. The latter is necessary since otherwise the sieve would produce hundreds of megabytes of output within minutes...

The example [I]steer.txt[/I] file reads:
[CODE]32000000025 KMIN
32001000000 KMAX
30 KSTEP
600 minimum weight for printing
[/CODE]
You may skip the text comments at the right. The printing condition means, that the k is only printed when the weight is higher or equal to the specified value (e.g. weight>=600 in the example). Note, that we use a smaller n-range (1-1000), therefore 600 is a rather high weight. The weights are roughly one tenth of the Nash weights. Also note the restriction of k<2^63 (signed long).

Usage is simply:
[CODE]multi5[/CODE]
for the example [I]steer.txt[/I] file you will get:
[CODE]multi5
32000060235 609
32000107425 622
32000193225 612
32000315325 605
32000497485 640
32000553585 618
32000703735 674
32000816445 601
32000982585 622
[/CODE]

If you want to store the results, you can simply redirect the output to a file, e.g.:
[CODE]multi5 > my_ks.txt[/CODE]
Of course it works the some way for [B]nash[/B] and [B]mnash[/B]...

Thomas11 2007-02-27 19:42

I forgot to mention:
For [B]nash[/B] and [B]mnash[/B] I used a precompiled static GMP library. I haven't tested the binaries on a Windows machine without the GMP lib so far, nor have I tested them on a non-P4 (non-SSE2) machine.
So, if you run into trouble, just let me know...

Flatlander 2007-02-27 20:46

Nash Crash
 
Nash crashes in Windows. I assume I need to download the library you mentioned? Could you provide a direct link please.

XP Home
Athlon XP 3200+

Thomas11 2007-02-28 10:09

1 Attachment(s)
[QUOTE=Flatlander;99536]Nash crashes in Windows. I assume I need to download the library you mentioned? Could you provide a direct link please.

XP Home
Athlon XP 3200+[/QUOTE]

I used the following (german) link:
[URL="http://www.bempf.de/c/gmp/gmp.html"]http://www.bempf.de/c/gmp/gmp.html[/URL]

But probably in your case the problem is, that the library is precompiled for SSE2 machines, but your Athlon doesn't have SSE2...

Currently I don't have any Athlons running under Windows. :no:
But I could try to compile GMP from scratch without the SSE2 options this evening...

Edit: amphoria was so kind to generate a Windows binary (attached below) for the older [B]nash3[/B] (which is essentially the same as [B]mnash[/B]). I haven't tested it so far, but perhaps it works on your Athlon...

Flatlander 2007-02-28 13:46

Nash3 works. Thank you.

Thomas11 2007-02-28 14:39

P3/Athlon binaries for Windows
 
1 Attachment(s)
I created a new set of Windows binaries by using a different precompiled GMP library from: [URL="http://cs.nyu.edu/exact/core/gmp/"]http://cs.nyu.edu/exact/core/gmp/[/URL]

The file contains [B]nash.exe[/B] and [B]mnash.exe[/B]. They are tested on an AthlonXP/Win2000 system and should work on P3 machines as well.

cipher 2009-05-11 13:04

Thomas 11
do you think multi5 code can be optimized to run faster on 64 bit OS?

Thanks
cipher

Thomas11 2009-05-11 13:21

[QUOTE=cipher;173138]do you think multi5 code can be optimized to run faster on 64 bit OS?[/QUOTE]

I wouldn't expect any increase in speed since the (current) code will not benefit from a 64 bit architecture (e.g. 64 bit registers). The program was written to fit just into the limitations (e.g. cache size etc.) of the 32 bit processors of that time. Of course one could rewrite some parts to gain some benefit from 64 bits, but this would require some further investigation.
Probably a complete rewrite in C/C++ would be necessary...

pepi37 2015-07-02 21:09

I search for this article and will say this
"old" nash for 93*10^n-1 gives -93 10 5030 5045
"new" nash gives "only" -93 3116 3123
So what is correct ?

Second: how to calculate nash weight from 1 to 1000 on base 3?
mnash calculate only base 2, right?

Thanks for answer

Thomas11 2015-07-03 11:02

[QUOTE=pepi37;405180]I search for this article and will say this
"old" nash for 93*10^n-1 gives -93 10 5030 5045
"new" nash gives "only" -93 3116 3123
So what is correct ?

Second: how to calculate nash weight from 1 to 1000 on base 3?
mnash calculate only base 2, right?

Thanks for answer[/QUOTE]

It seems that you mixed up those values:

The old Nash tool as given here in this thread was specifically created for k*2^n-1 and will yield:
[CODE]nash 93 --> 93 3116 3123[/CODE]
But this is the Nash weight for the sequence 93*2^n-1

The new (universal) Nash tool (originally created upon your request) and given in [URL="http://www.mersenneforum.org/showpost.php?p=358591&postcount=13"]another thread[/URL] yields the correct answer:
[CODE]nash -93 10 --> -93 5030 5045[/CODE]
This is the Nash weight for the sequence 93*10^n-1

BTW.: Note the sign change between the two versions: For the new one enter negative k for the Riesel side, e.g. -k*b^n+1 for k*^b^n-1.

Regarding your second question:
mnash is restricted to base 2. But one could easily write a little Python or Perl script which does the looping over k and calls the new Nash tool...

Thomas11 2015-07-03 12:17

1 Attachment(s)
[QUOTE=Thomas11;405221]mnash is restricted to base 2.[/QUOTE]

I prepared a new version of mnash which is now also capable for bases other than b=2.
For convenience the attached ZIP file also contains the latest single k universal base nash.exe.

A positive k means k*b^n+1, negative k means k*b^n-1 (e.g. entering as -k*b^n+1)

Usage examples are given below:

Nash weights for sequences k*3^n-1 (for even k=10-20):
[CODE]mnash -20 -10 2 3 (= kmin kmax kstep base)

-20 3 2960 2960
-18 3 2686 2667
-16 3 1430 1435
-14 3 1524 1523
-12 3 2359 2369
-10 3 4054 4038[/CODE]
Note the reversed order due to the negative k values. If base is omitted, b=2 is assumed.

and for k*7^n+1:
[CODE]mnash 10 20 2 7

10 7 4000 3979
12 7 2407 2411
14 7 0 0
16 7 3211 3210
18 7 2392 2387
20 7 0 0[/CODE]

Nash weight for the single sequence 14*17^n-1:
[CODE]nash -14 17

-14 17 803 800[/CODE]
Same here: If base is omitted, b=2 is assumed.

pepi37 2015-07-03 13:51

Mnash rules!
Thanks so much!

Thomas11 2015-07-06 08:15

1 Attachment(s)
I did some minor improvements to the "mnash" tool:

(1) The earlier version was restricted to k<2^31, the new one can handle k of arbitrary size.

(2) The values "kmin" and "kmax" now have the meaning of start and stop values and you're no longer restricted to (numerically) increasing order.

(3) The sign of the step size doesn't matter. It will be adjusted properly. So a step size of 2 may be entered as "2" oder "-2".

(4) If only kmin and kmax are given, a step size of 2 is assumed. And base=2, of course.


To give an example:
[CODE]mnash -2 -10 2 13

-2 13 3721 3713
-4 13 0 0
-6 13 1416 1414
-8 13 963 965
-10 13 0 0
[/CODE]

And for some very large Ks:
[CODE]mnash 123456789012345678901234567890 123456789012345678901234567880 2 7

123456789012345678901234567890 7 3543 3571
123456789012345678901234567888 7 1370 1345
123456789012345678901234567886 7 0 0
123456789012345678901234567884 7 2876 2886
123456789012345678901234567882 7 2171 2148
123456789012345678901234567880 7 0 0
[/CODE]

pepi37 2015-12-24 23:53

Can you make modification of this tool adding just one number

1 100 2 2 [COLOR=Red][B]10

[/B][COLOR=Black]Last number means: print only K that have weight 10 or less.[/COLOR]
[/COLOR]

Thomas11 2015-12-25 09:55

[QUOTE=pepi37;420122]Can you make modification of this tool adding just one number

1 100 2 2 [COLOR=Red][B]10

[/B][COLOR=Black]Last number means: print only K that have weight 10 or less.[/COLOR]
[/COLOR][/QUOTE]

I will add this feature when I'm back from Christmas vacations (don't have a real computer with me)...

pepi37 2015-12-27 22:04

Multi5 is still way faster then mnash.
So also can you just change behavior of last number

32000000025 KMIN 32001000000 KMAX 30 KSTEP 600 minimum weight for printing
Since if we use this tool we look at very small weight of number do that last number print only K less then not above then ( as it now)
With that output will be drastically smaller .
Thanks

Thomas11 2016-01-04 12:43

1 Attachment(s)
[QUOTE=pepi37;420122]Can you make modification of this tool adding just one number

1 100 2 2 [COLOR=Red][B]10

[/B][COLOR=Black]Last number means: print only K that have weight 10 or less.[/COLOR]
[/COLOR][/QUOTE]

Here comes the new version of MNash with the print filtering feature added.

Usage example:
[CODE]MNash.exe -1 -100 2 2 800[/CODE]

The additional parameter (800) controls the printing, e.g. the result line will only be printed if at least one of the two weights is less or equal to the limiting parameter. The output of the above example is thus:
[CODE] -11 2 795 791
-29 2 495 485
-37 2 630 629
-43 2 633 640
-59 2 639 642
-71 2 593 604
-73 2 800 818
[/CODE]

If looking for high weight sequences just enter the limit with a negative sign, e.g.:
[CODE]MNash.exe -1 -100 2 2 -3000[/CODE]

This will print only lines with weight >= 3000:
[CODE] -45 2 3747 3767
-69 2 3438 3437
-75 2 3181 3184
[/CODE]


All times are UTC. The time now is 12:28.

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