mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2014-05-07, 16:42   #2454
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

one thing I realized was that x=vecsort(x,,8) eliminated more than #x=#vecsort(x), because it also asked setisset(x) effectively which allows use to only use ones that are in order already.
science_man_88 is offline   Reply With Quote
Old 2014-05-07, 18:11   #2455
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post

Additional thought: you're looking for a partition x1 > ... > xn equal to the proper divisors (> 1) of x1 * xk. So a faster method would be to loop through the primes p which might be the least member, look for partitions of n-p with all parts at least q = nextprime(p+1) and at most q*(n-q)\nextprime(q+1), and then add on p 'by hand'. This trims off a lot of partitions to check, I think.
I did have difficulty trying to get yours to work, actually the reason I'm doing n-1 instead of n is because 1 is already eliminated that way so if prime p gets eliminated I'd look for partitions of n-(p+1) I might just make an outer parforprime ( a parallel forprime) loop to do this after figuring out a limit , and technically if n-1 is prime (n-1)^2 gets missed by your code.
edit: doh, what am I thinking I just realized something before I posted and forgot it already. [2,n-3] will catch all for primes above it as wells so unless I go down through the primes both the parforprime and others save none. edit2: nevermind I realized that I'm not looking up to n-1 again.

Last fiddled with by science_man_88 on 2014-05-07 at 18:30
science_man_88 is offline   Reply With Quote
Old 2014-05-08, 14:04   #2456
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
one thing I realized was that x=vecsort(x,,8) eliminated more than #x=#vecsort(x), because it also asked setisset(x) effectively which allows use to only use ones that are in order already.
#x == #vecsort(x) is true for any vector x, since vecsort doesn't remove any elements unless you give it flag 8.

Set(x) is basically a better version of vecsort(x,,8) if your version is new enough that Set([1])==[1] .
CRGreathouse is offline   Reply With Quote
Old 2014-05-08, 14:22   #2457
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
I did have difficulty trying to get yours to work, actually the reason I'm doing n-1 instead of n is because 1 is already eliminated that way so if prime p gets eliminated I'd look for partitions of n-(p+1)
Sounds good, that's what I figured.

Quote:
Originally Posted by science_man_88 View Post
parforprime ( a parallel forprime)
You should test this before using to make sure your version can actually make reasonable use of it. Try something like

parforprime(p=2,7, runs_for_10_seconds())

to see if it runs in ~10 seconds or ~40 seconds (assuming 4 cores, adjust to suit otherwise).
CRGreathouse is offline   Reply With Quote
Old 2014-05-08, 18:04   #2458
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

parforprime still didn't make sense and seems to be slower for simple things. on another note:

Code:
p=11;a=binary(2^((p-1)/2-1)-1);s=14;for(x=1,#a,s=(Mod(s,(2^p-1))^2-2)^2-2);s
here's another way to do the lucas lehmer test I was trying to make it close to:

http://www.mersenne.org/various/math...rial_factoring , anyways off to make my other code better I guess.
science_man_88 is offline   Reply With Quote
Old 2014-05-09, 05:08   #2459
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

10111010110112 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
parforprime still didn't make sense and seems to be slower for simple things.
It's definitely slower for simple things -- lots of overhead. I wouldn't consider doing less than a million cycles with each iteration.
CRGreathouse is offline   Reply With Quote
Old 2014-05-09, 12:40   #2460
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
It's definitely slower for simple things -- lots of overhead. I wouldn't consider doing less than a million cycles with each iteration.
well there's that, but also once p=2 is done it covers everything else because every value in the limits [amin,amax] will fall between 2,n-3 the only thing this misses is when n-1 is prime. So doing it first doesn't make sense but even doing it in reverse order doesn't either without a check on if it's already in c because as p decreases the range [p,n-(p+1)] is larger than [nextprime(p),n-(nextprime(p)+1)], for some reason I'm getting your code to be slower than mine overall.
science_man_88 is offline   Reply With Quote
Old 2014-05-09, 13:52   #2461
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Which codes are you comparing? I think we've both posted several.
CRGreathouse is offline   Reply With Quote
Old 2014-05-09, 14:14   #2462
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Which codes are you comparing? I think we've both posted several.
I guess I made alterations that made my code faster:

http://mersenneforum.org/showpost.ph...postcount=2453

if I take out the solve part you have that my original didn't yours takes 378 ms if I add your solve in my code takes 129 ms so it's really only the solve I can find as faster. if I add in the ( I typed it wrong before) improvement of using the check x==vecsort(x,,8) I get it down to ~111 ms for mine. and even with your solve back into it plus an equivalent to my check by using Vec(x)==Set(x) yours doesn't go below 200 ms.

Last fiddled with by science_man_88 on 2014-05-09 at 14:41
science_man_88 is offline   Reply With Quote
Old 2014-05-09, 15:25   #2463
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Since you didn't answer my question I won't bother doing my own analysis.
CRGreathouse is offline   Reply With Quote
Old 2014-05-09, 18:31   #2464
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Since you didn't answer my question I won't bother doing my own analysis.
I had a link to the codes I altered from, and how altering them changed things.
science_man_88 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 06:55.


Fri Aug 6 06:55:30 UTC 2021 up 14 days, 1:24, 1 user, load averages: 2.53, 2.64, 2.71

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.