On 4/26/2011 2:10 AM, Dima Kogan wrote:
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.
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


On Mon, 25 Apr 2011 17:30:31 -0600
Craig DeForest<[email protected]>  wrote:

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

Aha. That appears to be the correct syntax. Thanks much for that. Is there a lot
of knowledge of PP left on this list, or is reading the source the main method
for figuring it out these days? I've seen the following undocumented flags in
various PP definitions: c,a,phys. Anybody knows what those do?

In my experience, reading the source can be the quickest
way to resolve questions about functionality.  As is
often the case, documentation lags development.  PP is
on my list of "things to grok" about PDL but I find the
code particularly difficult to follow.  There has been
discussion about a possible colloquium on the subject.

In any case there's enough documentation for me to have completed a
first cut to the OpenCV bindings:

https://github.com/dkogan/PDL-OpenCV

These bindings appear to work with some caveats (all piddles must be pre-made
when calling the functions, some extra data copying may be done (as per my
previous post), etc). Any testing and/or comments are welcome.

Thanks, I'm looking forward to trying them out.
OpenCV bindings have been on the PDL wish list
for some time...  :-)

--Chris

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to