mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

3.14159 2010-08-17 16:37

In the long run, my idea fails, because nonmem fails to work as directed. I think I'm going to have to revert back to the TF switch on PFGW.

Last idea:
if(n=!p*a + lift(Mod(-1,p)/(m!)), print(n)))

3.14159 2010-08-17 16:55

Well, it works, but only for individual divisors. If I add more than one prime, it loops/repeats. I need to edit it to include the and condition a few hundred times.

CRGreathouse 2010-08-17 16:56

[QUOTE=3.14159;225863]In the long run, my idea fails, because nonmem fails to work as directed. I think I'm going to have to revert back to the TF switch on PFGW.[/QUOTE]

As you will. For my recent (ongoing, unfortunately) project I found a huge speedup with sieving vs. trial division: I could remove more composites (higher bounds) in less time with sieving. Actually I found it worthwhile to spend a good fraction of my time sieving because of the amount of effort saved by avoiding primality tests.

CRGreathouse 2010-08-17 16:59

[QUOTE=3.14159;225867]Well, it works, but only for individual divisors. If I add more than one prime, it loops/repeats. I need to edit it to include the and condition a few hundred times.[/QUOTE]

You need to store the results in a vector rather than printing, since your lists will get large. For my small project I had 2 million candidates and 100 million primes; yours may not be as small. (I hoped to finish this yesterday so as to free up cycles for my new project that I've talked about, but no such luck.)

3.14159 2010-08-17 17:03

[QUOTE=CRGreathouse]You need to store the results in a vector rather than printing, since your lists will get large. For my small project I had 2 million candidates and 100 million primes; yours may not be as small. (I hoped to finish this yesterday so as to free up cycles for my new project that I've talked about, but no such luck.)
[/QUOTE]

Vectors? They can only store returns. That would mean I would be forced to sift through the file for every single prime, counting by p to remove a number every p numbers skipped. Dreadfully inefficient, at best.

Ex: Sieving out 509 for k * 360! + 1:
Liftmod(509, 360!) = 474.

Suppose the k-value range is n between 1 and 60k. That would be 117 values removed. Manual removal of values is dreadfully inefficient.

CRGreathouse 2010-08-17 17:07

[QUOTE=3.14159;225873]Vectors? They can only store returns. That would mean I would be forced to sift through the file for every single prime, counting by p to remove a number every p numbers skipped. Dreadfully inefficient, at best.[/QUOTE]

I'm not sure exactly what you mean by "they can only store returns", but I'm pretty sure it's wrong.

There's no need to use an intermediate file, I don't know why you'd suggest that. You keep one vector that starts out all 0s, you sieve, and at the end of the process each remaining 0 corresponds to a candidate which is not divisible by any of the primes you sieved out.

3.14159 2010-08-17 17:09

[QUOTE=CRGreathouse]I'm not sure exactly what you mean by "they can only store returns", but I'm pretty sure it's wrong.
[/QUOTE]

You can't make a vector out of print values (Well, the vector formed is 0, but you get the idea.). The vector is made of return values. I would have to store it in a file, and manually remove all the bad k-values.

CRGreathouse 2010-08-17 17:13

[QUOTE=3.14159;225875]You can't make a vector out of print values (Well, the vector formed is 0, but you get the idea.). The vector is made of return values. I would have to store it in a file, and manually remove all the bad k-values.[/QUOTE]

You can store strings (this is my best guess as to what you mean by "print values") in vectors if you like. But there's no need to do that -- you just need a 0 or a 1 in each entry.

And there's absolutely no reason to store the vector in a file (though Pari could certainly do that).

I still don't know what you mean by return values, or why you think printing has anything to do with any of this.

3.14159 2010-08-17 17:30

[QUOTE=CRGreathouse]You can store strings (this is my best guess as to what you mean by "print values") in vectors if you like. But there's no need to do that -- you just need a 0 or a 1 in each entry.
[/QUOTE]

By that, I was referencing a list of printed b-values. A vector can't be formed of them.

CRGreathouse 2010-08-17 17:59

[QUOTE=3.14159;225878]By that, I was referencing a list of printed b-values. A vector can't be formed of them.[/QUOTE]

OK... so why print them in the first place? Replace print(foo" is bad") with v[foo] = "bad", or v[foo] = 1, or whatever you like.

3.14159 2010-08-17 18:16

[QUOTE=CRGreathouse]OK... so why print them in the first place? Replace print(foo" is bad") with v[foo] = "bad", or v[foo] = 1, or whatever you like.
[/QUOTE]

It is unclear what you mean here.

em2 can't be made a vector.

I think there's simply no way to do it using vectors.


All times are UTC. The time now is 23:05.

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