mersenneforum.org  

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

Reply
 
Thread Tools
Old 2014-05-14, 23:16   #2465
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default polynomial form

I know that:
2x+1 single mersennes when x is the previous single mersenne
2x^2+4x+1 double mersennes when x is the previous double mersenne

I know the relation of the exponents of a triple mersenne as they are the double mersennes but does anyone know of a general form other than (2^y+1)*(2^x-1) for triple, quadruple, quintuple, etc. mersennes ? edit: sorry wrong thread for some reason I thought this was the theory of mersenne primes thread

Last fiddled with by science_man_88 on 2014-05-14 at 23:20
science_man_88 is offline   Reply With Quote
Old 2014-05-17, 16:57   #2466
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

838410 Posts
Default

does anyone know why they haven't merged Pol and Polrev ? I could see a newer version with {n=1} being a switch where n=1 makes it Pol and -1 makes it Polrev, though I guess that's because I'm trying to make my own version that does something like both.
science_man_88 is offline   Reply With Quote
Old 2014-05-17, 19:42   #2467
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
does anyone know why they haven't merged Pol and Polrev ?
Why would they?
CRGreathouse is offline   Reply With Quote
Old 2014-05-17, 19:44   #2468
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Why would they?
I was just thinking that it would reduce the number of functions, but I can't make anything that quick my best attempt involved parsum:

Code:
Pols(t,v='x,{n=1})=if(n==1,parsum(w=1,#t-1,t[w]*v^(#t-w),t[#t]),parsum(w=2,#t,t[w]*v^(#t-(#t-w+1)),t[1]))
edit: which is about 1200 times as slow for a vector of length 10000

Last fiddled with by science_man_88 on 2014-05-17 at 19:45
science_man_88 is offline   Reply With Quote
Old 2014-05-22, 22:04   #2469
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Code:
parmatrix(m,n,{X},{Y},{expr=0})={
a=matrix(m,n,x,y,0);
parfor(x=1,n,
        parvector(m,y,
                      a[x,y]=eval(expr)
                      )
        )
     ;a
}
I was trying to make a parallel function for matrices ( in case it might ever be useful)

Last fiddled with by science_man_88 on 2014-05-22 at 22:05
science_man_88 is offline   Reply With Quote
Old 2014-05-22, 23:40   #2470
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

You forgot my().
CRGreathouse is offline   Reply With Quote
Old 2014-05-22, 23:43   #2471
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
You forgot my().
It doesn't fully work as written even with my, what am I missing?

Last fiddled with by science_man_88 on 2014-05-22 at 23:53 Reason: adding question mark
science_man_88 is offline   Reply With Quote
Old 2014-05-23, 13:33   #2472
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

I would do
Code:
parmatrix(m,n,expr=(a,b)->0)={
  my(a=matrix(m,n));
  parfor(x=1,m,
    for(y=1,n,
      a[x,y]=expr(x,y)
    )
  );
  a
};
with the understanding that the third argument needs to be given as a closure:

Code:
f(x,y)=x^2+sigma(y);
parmatrix(5, 5, f) \\ user function called by name
parmatrix(4, 6, gcd) \\ built-in function called by name
parmatrix(4, 4, (x,y) -> x+y) \\ anonymous function
You can't define a function in gp with a true expr argument (you'd need to use the PARI library directly in C).
CRGreathouse is offline   Reply With Quote
Old 2014-05-23, 14:03   #2473
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

100000110000002 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
I would do
Code:
parmatrix(m,n,expr=(a,b)->0)={
  my(a=matrix(m,n));
  parfor(x=1,m,
    for(y=1,n,
      a[x,y]=expr(x,y)
    )
  );
  a
};
with the understanding that the third argument needs to be given as a closure:

Code:
f(x,y)=x^2+sigma(y);
parmatrix(5, 5, f) \\ user function called by name
parmatrix(4, 6, gcd) \\ built-in function called by name
parmatrix(4, 4, (x,y) -> x+y) \\ anonymous function
You can't define a function in gp with a true expr argument (you'd need to use the PARI library directly in C).
Okay, Thanks for the code and hint. One further question what function won't return all 0's from the matrix default of 0's ?

Last fiddled with by science_man_88 on 2014-05-23 at 14:14
science_man_88 is offline   Reply With Quote
Old 2014-05-23, 15:01   #2474
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
One further question what function won't return all 0's from the matrix default of 0's ?
I don't know what you mean. I gave three examples of functions that don't return all 0s.
CRGreathouse is offline   Reply With Quote
Old 2014-05-23, 15:14   #2475
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
I don't know what you mean. I gave three examples of functions that don't return all 0s.
I tried every one of those and got back 0's:

Code:
(11:48) gp > parmatrix(m,n,expr=(a,b)->0)={
  my(a=matrix(m,n));
  parfor(x=1,m,
    for(y=1,n,
      a[x,y]=expr(x,y)
    )
  );
  a
};
(12:12) gp > f(x,y)=x^2+sigma(y);
(12:13) gp > parmatrix(5, 5, f)
%67 =
[0 0 0 0 0]

[0 0 0 0 0]

[0 0 0 0 0]

[0 0 0 0 0]

[0 0 0 0 0]

(12:13) gp > parmatrix(4, 6, gcd)
%68 =
[0 0 0 0 0 0]

[0 0 0 0 0 0]

[0 0 0 0 0 0]

[0 0 0 0 0 0]

(12:13) gp > parmatrix(4, 4, (x,y) -> x+y)
%69 =
[0 0 0 0]

[0 0 0 0]

[0 0 0 0]

[0 0 0 0]
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:29 UTC 2021 up 14 days, 1:24, 1 user, load averages: 2.49, 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.