> On Mon, 25 Apr 2011 19:04:42 -0400 > Chris Marshall <[email protected]> wrote: > > On 4/23/2011 7:00 PM, Dima Kogan wrote: > > Hi. I'm using PP to define a function that takes a piddle with some > > constant dimensions, and I'm having a bit of trouble. > > > > The function is defined as: > > > > pp_def("testfunc", > > Pars => ' a(n,1); [o]b(n,2);', > > Code => '' > > ); > > I looked at the various signatures in the PDL > source and found the following usage: > > pp_def("testfunc", > Pars => ' a(n,m=1); [o]b(n,p=2);', > Code => '' > ); > > Does that work better? --Chris > > > If I try to call this function with > > > > my $a = testfunc( pdl(1,2,3) ); > > > > the perl simply croaks with "Out of memory!". Calling this function > > with > > > > testfunc( pdl(1,2,3), my $a ); > > > > doesn't crash immediately, but the output piddle is n-by-1 NOT > > n-by-2. I now realize that in the definition above, I'm not asking > > for an n-by-2, piddle, rather the "2" is a name for that dimension > > that can have an arbitrary size. I discovered that I can make that > > function work my adding another key to pp_def(): > > > > RedoDimsCode => '$SIZE(1) = 1; $SIZE(2) = 2;', > > > > This works in the simplest case, but not completely. If I define an > > input piddle to be n-by-2 this way, and pass in an n-by-1 piddle > > instead of n-by-2, nothing complains. Is this the correct behavior? > > Is "RedoDimsCode" the right way to do this? Should PP treat > > numerical dimensions as constant sizes instead of just another > > named dimension? Thanks.
Hi Chris. I've been looking around a bit more and found a patch to the PP documentation that describes both the RedoDimsCode syntax and the '=' in the Pars that you mentioned: http://www.mail-archive.com/[email protected]/msg00320.html This has not been merged, but perhaps should be. Also, I did a preliminary port of another library to PDL via PP (https://github.com/dkogan/PDL-Triangle). This required an output piddle whose size wasn't known at runtime. I used $RESIZE() for that and it seems to work well. I can document $RESIZE(), as I understand it, in the PP POD, but the source has a concerning warning: "RESIZE USED: DO YOU KNOW WHAT YOU ARE DOING???\n" Any insight to the pitfalls of $RESIZE()? dima _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
