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)

axn 2010-08-11 18:06

[QUOTE=3.14159;224940]A small inconvenience: [/QUOTE]
Definition of modbm?

CRGreathouse 2010-08-11 18:29

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?

3.14159 2010-08-11 18:38

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

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))));[/code]

NOTE: p(m) = p[sub]m[/sub]#

My normal looping function is normally b(m).

CRGreathouse 2010-08-11 18:40

Well there's your problem. modbmpsp is expecting a return value and modbm doesn't give one, so modbmpsp treats the value as 0.

3.14159 2010-08-11 18:42

[QUOTE=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.
[/QUOTE]

The code snippet for modbmpsp [B]does not ask for any return values.[/B]

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

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

CRGreathouse 2010-08-11 18:48

[QUOTE=3.14159;224950]The code snippet for modbmpsp [B]does not ask for any return values.[/B][/QUOTE]

I've highlighted the part where a return value is expected.
[code]modbmpsp(x,n,m)=if(isPRP([COLOR="Red"]modbm(x,n,m)[/COLOR],b=2),print(modbm(x,n,m))[/code]

But modbm does not return anything, so the highlighted portion is treated as 0 by modbmpsp.

[QUOTE=3.14159;224950]If it were the PRP code that would be the problem:

It returns 1, which means there should be no issue.[/QUOTE]

I don't know what you mean by "it" here.

3.14159 2010-08-11 18:48

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, ...

CRGreathouse 2010-08-11 18:51

[QUOTE=3.14159;224953]Ah, I see the issue now.. It merely copies modbm because there's some sort of error in the PRP command.[/QUOTE]

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.

3.14159 2010-08-11 18:56

[QUOTE=CRGreathouse]But modbm does not return anything, so the highlighted portion is treated as 0 by modbmpsp.
[/QUOTE]

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.

CRGreathouse 2010-08-11 18:59

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.

science_man_88 2010-08-11 19:01

[QUOTE=3.14159;224953]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, ...[/QUOTE]

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.


All times are UTC. The time now is 22:21.

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