![]() |
|
|
#2476 |
|
Aug 2006
3×1,993 Posts |
Would you paste in your startup message, like
Code:
GP/PARI CALCULATOR Version 2.8.0 (development 16370-23a2ae3)
i686 running mingw (ix86/GMP-5.1.3 kernel) 32-bit version
compiled: Apr 14 2014, gcc version 4.8.2 (GCC)
threading engine: single
(readline v6.2 enabled, extended help enabled)
Copyright (C) 2000-2014 The PARI Group
PARI/GP is free software, covered by the GNU General Public License, and comes
WITHOUT ANY WARRANTY WHATSOEVER.
Code:
parmatrix(m,n,expr=(a,b)->0)={
my(a=matrix(m,n));
for(x=1,m,
for(y=1,n,
a[x,y]=expr(x,y)
)
);
a
};
|
|
|
|
|
|
#2477 | ||
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
Quote:
Code:
(12:44) gp > parmatrix(m,n,expr=(a,b)->0)={
my(a=matrix(m,n));
for(x=1,m,
for(y=1,n,
a[x,y]=expr(x,y)
)
);
a
};
(14:03) gp > parmatrix(10,10,f(x,y)=x^2+sigma(y))
%7 =
[ 2 4 5 8 7 13 9 16 14 19]
[ 5 7 8 11 10 16 12 19 17 22]
[ 10 12 13 16 15 21 17 24 22 27]
[ 17 19 20 23 22 28 24 31 29 34]
[ 26 28 29 32 31 37 33 40 38 43]
[ 37 39 40 43 42 48 44 51 49 54]
[ 50 52 53 56 55 61 57 64 62 67]
[ 65 67 68 71 70 76 72 79 77 82]
[ 82 84 85 88 87 93 89 96 94 99]
[101 103 104 107 106 112 108 115 113 118]
(14:04) 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;
(14:04) gp > parmatrix(10,10,f(x,y)=x^2+sigma(y))
%9 =
[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 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]
[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 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]
(14:04) gp > parmatrix(m,n,expr=(a,b)->0)=my(a=matrix(m,n));for(x=1,m,parvector(n,y,a[x,y]=expr(x,y)));a;
(14:05) gp > parmatrix(10,10,f(x,y)=x^2+sigma(y))
%11 =
[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 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]
[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 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]
|
||
|
|
|
|
|
#2478 |
|
Aug 2006
3·1,993 Posts |
Actually, on second thought, this might be a problem with the threading model -- the other threads can't change the global matrix a. Hmm. I don't know of an easy solution, maybe there is something that can be done with inline().
The 'right' solution would require working in PARI. You'd generate each column in parallel, then combine them with something like mkmat. |
|
|
|
|
|
#2479 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Quote:
Code:
parmatrix(m,n,expr=(a,b)->0)={
my(a=matrix(m,n));
for(x=1,m,
a[x,]=parvector(n,y,eval(expr(x,y)))
);a;
Last fiddled with by science_man_88 on 2014-05-23 at 17:56 |
|
|
|
|
|
|
#2480 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
I tried the vector one again but with only one parallel function ( though I wonder if breaking parvector into pareval and vector could work):
Code:
parmatrix1(m,n,expr(a,b)->0)
=my(a=Vec(matrix(m,n)));
for(x=1,n,
a[x]=parvector(m,y,eval(expr(x,y)))
);
a=Mat(a)
Last fiddled with by science_man_88 on 2014-05-24 at 12:01 |
|
|
|
|
|
#2481 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
I've been reading up on set's etc. ( partly brought on my the fog comment by RDS) and I'm wondering why forpart() doesn't allow the variable to go over the partitions of a set (aka the elements of the power set of the set x=[1,2,3,4,5,6,7,8,9,10,11,12] for example). I'm guessing there's probably already a Set based function like this ?
|
|
|
|
|
|
#2482 |
|
Aug 2006
3·1,993 Posts |
I notice also that you have "threading model: single" which means that you can't execute code in parallel anyway.
|
|
|
|
|
|
#2483 | |
|
Aug 2006
3×1,993 Posts |
Quote:
Code:
for(i=0,n!-1, p = numtopart(n, i); print(p)) If you want to loop over subsets of a set, use Code:
for(i=0,2^#v-1, p = vecextract(v,i); print(p)) |
|
|
|
|
|
|
#2484 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
once I saw them in order I thought it would cut a check out of aligentry0 but for n=73 it increases the number of vectors to checks to >19 * numbpart(73)^3 when the whole before took numbpart(73)+14.
Last fiddled with by science_man_88 on 2014-05-28 at 01:49 |
|
|
|
|
|
#2485 |
|
"Forget I exist"
Jul 2009
Dumbassville
203008 Posts |
I made a recent edit on the OEIS but I know a further formula from it that leads to the Fermat quotients however my codes ( based on quick ways of setting things up that I've read in the OEIS) crashes at b(1152), I was hoping someone could suggest an edit that wouldn't crash it:
Code:
a(n)=if(n,4*a(n-1)+1,0) Code:
b(n)=p=prime(n);(3*a((p-1)/2))/p Last fiddled with by science_man_88 on 2014-10-03 at 22:45 Reason: editing down the upper working bound. |
|
|
|
|
|
#2486 | |
|
Aug 2006
597910 Posts |
Quote:
|
|
|
|
|
![]() |
| 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 |