![]() |
I don't think that is it, as the result is supposed to be negative. -67^10, for example, works just fine. The different versions of Pari also print the same result for -167^10. To remove that effect, change the example to:[code]ispower(-16871927924929095158449)[/code]and one gets the same result (Pari 2.5.5 gives 5, past that commit it starts giving an mplog domain error). This should not produce an error. Note that -101^10 and smaller gives a correct result, but 103 and higher gives the error.
Lest we think this is a problem with evens, we can try -7079^5 which works and -8093^5 which does not. Or -(8093^5) if preferred. |
[strike]Ah, ok, I understand now, but you confused me with that "5". It should return 10, and not 5. Why should it return 5? :surprised:[/strike]
scrap tat, I am stupid. I go to sleep. 0:08 AM here.. |
Since it is negative, we have to get rid of even powers. So for instance, ispower(-4) returns 0 , ispower(-8) returns 3, ispower(-16) returns 0, ispower(-32) returns 5, etc. For -167^10: -27889^5 yields -167^10 but there isn't any way to raise to an even power and yield a negative result -- hence no 10. Similarly -167^20 yields 5, and -167^(3*5*7*2*2*2*2*2*2) yields 105 (3*5*7).
Edit: nvm, I see you got it. I noticed my module wasn't defined for negative powers so decided to add that since Pari had it and it made sense. It was interesting. |
1 Attachment(s)
I told you I am not arguing with you anymore :razz:
Well, at least they had something to fix from the former versions, and broke it more... I just dug into my archives: [ATTACH]11908[/ATTACH] |
[QUOTE=LaurV;386564]I told you I am not arguing with you anymore :razz:[/QUOTE] :( I'm sorry, I wasn't arguing but trying to write things out in detail to convince myself.
|
Haha, why are you so defensive? (don't need to reply, this is a rhetoric question).
That (as the first time too) was a show of respect for you from my side, and not a blame. It was a [URL="http://en.wikipedia.org/wiki/Compliment"]compliment[/URL]. I like to win my arguments, and telling you that I don't want to argue with you means that I evaluated the chances and I think I will lose, and I want to avoid that :razz: Like putting you in the same row with axn, Batalov, and few other guys here that I can count on the fingers of a single hand. It is even harder for me to tell that to a woman, because usually am a misogynist son of a bleach. |
another attempt at mass TF of mersenne numbers ( in parallel)
[CODE]{
my(a=vector(g=1<<12,n,[]),b=[0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1],p=parvector(primepi(1<<15)-1,n,prime(n+1))); p=setminus(p,parselect(v->v%4==3&&ispseudoprime(v<<1+1)&&b[(v<<1+1)%24+1]&&isprime(v<<1+1)||setminus(MeVec,[v])!=MeVec,p)); p=parvector(2,n,parselect(v->v%3==n,p)); for(x=1,g, t=x<<1; m=x%3; if(m==0, a[x]=concat(a[x],o=parselect(v->ispseudoprime(l=v*t+1)&&b[(l)%24+1]&&isprime(l)&&!component(Mod(2,l)^v-1,2),concat(p[1],p[2]))), m==1, a[x]=concat(a[x],o=parselect(v->ispseudoprime(l=v*t+1)&&b[(l)%24+1]&&isprime(l)&&!component(Mod(2,l)^v-1,2),p[1])), m==2,a[x]=concat(a[x],o=parselect(v->ispseudoprime(l=v*t+1)&&b[(l)%24+1]&&isprime(l)&&!component(Mod(2,l)^v-1,2),p[2])) ); if(m!=0, p[m]=setminus(p[m],o), p[1]=setminus(p[1],setintersect(p[1],o)); p[2]=setminus(p[2],setintersect(p[2],o)) ) ); a };[/CODE] this is still slower than the non paralleled version I made recently: [CODE]{ my(c=1<<12,a=vector(c,n,[]),b=[0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1]); forprime(p=3,1<<15, r=p<<1+1; j=(p%3==2); if((p%4==3 && ispseudoprime(r) && b[r%(#b)+1] && isprime(r))||setminus(MeVec[p])!=MeVec, , l=1<<((p-1)/2); forstep(x=if(j,3,2),if(l<c,l,c),[1,2], q=(x*p)<<1+1; if(ispseudoprime(q) && b[q%#b+1] && isprime(q) && component(Mod(2,q)^p-1,2)==0, a[x]=concat(a[x],p); break() ) ) ) ); a; };[/CODE] is there anything I can do to speed up either version ? they currently run around 7 seconds on my computer. |
I can't figure out what's going on -- I would have expected this to cause an error, with setminus(MeVec[p]) not having enough arguments and all. Why don't you explain what you're trying to do?
|
[QUOTE=CRGreathouse;389054]I can't figure out what's going on -- I would have expected this to cause an error, with setminus(MeVec[p]) not having enough arguments and all. Why don't you explain what you're trying to do?[/QUOTE]
I used a text editor it should read MeVec,p I'm trying to see if I can successfully use the parallel programming part to actually win out over the non parallel programming by a significant margin, it's doing TF on mersenne numbers 2^q-1 (q in p (a vector of primes) in the parallel version) which get narrowed through conditions known to eliminate exponents early. it then goes on to check the checks are ordered such as to eliminate further checks from being needed. most things that I use more than once get a variable name assigned to them so I don't continue to calculate them for each check. I guess I know a few more things that may decrease the time but one thing I have in the non parallel version seems to slow down the parallel version ( making sure x keeps the number below the sqrt of the mersenne number to be tested) before the loop I divide p into groups mod 6 so I don't test unnecessary x for each v in the parselects. I have tried other things but not in this current code like [][x%3+1] around what is now in the if statement ( laid out as a switch case) but then a lot of things got doubled partly because I didn't have the setminus against o I think. but it's basically eliminating candidates that don't work then testing potentially viable candidates. |
[QUOTE=science_man_88;389055]I'm trying to see if I can successfully use the parallel programming part to actually win out over the non parallel programming by a significant margin, it's doing TF on mersenne numbers 2^q-1[/QUOTE]
OK, so first things first: this should be its own function, which you can call for a single value of q. The function shouldn't know or care about the rest of the vector. Something like this: [code]merFac(q, lim=1e4)={ forstep(p=2*q+1,lim,2*q, if (Mod(2, p)^q==1, return(p)) ); 0 \\ Couldn't find a factor };[/code] Then you can run this function on all the values of your vector: [code]parapply(merFac, p)[/code] |
[QUOTE=CRGreathouse;389061]OK, so first things first: this should be its own function, which you can call for a single value of q. The function shouldn't know or care about the rest of the vector. Something like this:
[code]merFac(q, lim=1e4)={ forstep(p=2*q+1,lim,2*q, if (Mod(2, p)^q==1, return(p)) ); 0 \\ Couldn't find a factor };[/code] Then you can run this function on all the values of your vector: [code]parapply(merFac, p)[/code][/QUOTE] though it doesn't quite do what my code did ( group p based on k) this alone is too much faster to ignore I can do a test up to 2^26 edit:(with the first 2^15 primes greater than 3) just slightly more than what my code could do to 2^12 edit2:( for the primes up to 2^15 greater than 3) |
| All times are UTC. The time now is 06:55. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.