mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-08-11, 18:06   #254
axn
 
axn's Avatar
 
Jun 2003

32·5·113 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
A small inconvenience:
Definition of modbm?
axn is offline   Reply With Quote
Old 2010-08-11, 18:29   #255
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Cute trick, axm. I didn't realize that valuation threaded over vectors, column or otherwise.

Pi, I'd need to see modbm to say. Also, modbmpsp doesn't have matched parentheses -- did you leave something off?

Last fiddled with by CRGreathouse on 2010-08-11 at 18:30
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 18:38   #256
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Pi, I'd need to see modbm to say. Also, modbmpsp doesn't have matched parentheses -- did you leave something off?
Here is modbm:

Code:
modbm(x,n,m)=for(n=x,n,if(isprime(n*p(m)^2+1)&isprime(2*(n*p(m)^2+1)-1),print((n*p(m)^2+1)*(2*(n*p(m)^2+1)-1))));
NOTE: p(m) = pm#

My normal looping function is normally b(m).

Last fiddled with by 3.14159 on 2010-08-11 at 18:41
3.14159 is offline   Reply With Quote
Old 2010-08-11, 18:40   #257
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Well there's your problem. modbmpsp is expecting a return value and modbm doesn't give one, so modbmpsp treats the value as 0.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 18:42   #258
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Well there's your problem. modbmpsp is expecting a return value and modbm doesn't give one, so modbmpsp treats the value as 0.
The code snippet for modbmpsp does not ask for any return values.

If it were the PRP code that would be the problem:

It returns 1, which means there should be no issue.

Last fiddled with by 3.14159 on 2010-08-11 at 18:48
3.14159 is offline   Reply With Quote
Old 2010-08-11, 18:48   #259
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
The code snippet for modbmpsp does not ask for any return values.
I've highlighted the part where a return value is expected.
Code:
modbmpsp(x,n,m)=if(isPRP(modbm(x,n,m),b=2),print(modbm(x,n,m))
But modbm does not return anything, so the highlighted portion is treated as 0 by modbmpsp.

Quote:
Originally Posted by 3.14159 View Post
If it were the PRP code that would be the problem:

It returns 1, which means there should be no issue.
I don't know what you mean by "it" here.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 18:48   #260
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

69016 Posts
Default

Ah, I see the issue now.. It merely copies modbm because there's some sort of error in the PRP command.

I have an idea: I will change the snippet to: if(isPRP(modbm(x,n,m),b=2)==1, ...

Last fiddled with by 3.14159 on 2010-08-11 at 18:52
3.14159 is offline   Reply With Quote
Old 2010-08-11, 18:51   #261
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Ah, I see the issue now.. It merely copies modbm because there's some sort of error in the PRP command.
If by "the PRP command" you mean the function isPRP, then no: this problem will occur regardless of how that function is written. If you mean something else, please specify.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 18:56   #262
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
But modbm does not return anything, so the highlighted portion is treated as 0 by modbmpsp.
Ah. Okay. I have it set to "print".

But it will only return that particular value.

I will set it as part of the loop of a function similar to modbm.

I will name it modbm2.

Last fiddled with by 3.14159 on 2010-08-11 at 18:58
3.14159 is offline   Reply With Quote
Old 2010-08-11, 18:59   #263
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

If you fix that, does it work? If so, great. If not, please post the modified code, seeing that both modbmpsp and modbm needed to be changed. (Edit: all the code, if you can -- p, modbm*, isPRP, and whatever else you're calling.)

Also, can you describe what these functions are supposed to do? Using addhelp is good practice, but any sort of description could help us follow what you're going for here.

Last fiddled with by CRGreathouse on 2010-08-11 at 19:02
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:01   #264
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Ah, I see the issue now.. It merely copies modbm because there's some sort of error in the PRP command.

I have an idea: I will change the snippet to: if(isPRP(modbm(x,n,m),b=2)==1, ...
look to get a value out of a function and used by other functions if the first code returns nothing it is assumed to return 0 I think and so the value you are test as the first part of if (isprp() or what ever that part is is returning 0 since its variables are used later with no initial value they are assumed 0 and so mod by 0 error occurs. so to solve it the value outside of 0 of the other function so that other functions can use it.
science_man_88 is offline   Reply With Quote
Reply



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:34 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.