Ah. Thanks, Chris -- I meant to respond to Dima before but it fell
off the radar.
One other point: Dima, you probably don't want to force your input to
have two input dimensions and
also be n-by-1: in that case your algorithm probably really wants
just a single active dimension. I suggest
trying a signature like
Pars => 'a(n); [o]b(n,p=2);',
(as Chris suggested with the output size). Then your operator becomes
a sort of inverse-collapse operation.
Depending on how you think about the output (is it a collection of 2 n-
tuples? Or is it more naturally a
collection of n 2-tuples?) you also might want to rearrange the output
dimensions to (p=2,n).
Kindly,
Craig
On Apr 25, 2011, at 5:04 PM, Chris Marshall 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.
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl