Adam,

At the expense of learning yet-more gnarly internals of PDL, I'd suggest trying the Inline::Pdlpp module to write your code. It has the advantage that you don't need to mess around with Makefile.PL files. Once you get your code working you may decide to migrate it into an actual module, and then you can enjoy the delights of PDL makefiles...

Here's an example taken from the Inline::Pdlpp documentation (note this comes with PDL, even though it does not begin with PDL):

          # example script inlpp.pl
          use PDL; # must be called before (!) 'use Inline Pdlpp' calls

use Inline Pdlpp; # the actual code is in the __Pdlpp__ block below

          $a = sequence 10;
          print $a->inc,"\n";
          print $a->inc->dummy(1,10)->tcumul,"\n";

          __DATA__

          __Pdlpp__

          pp_def('inc',
                 Pars => 'i();[o] o()',
                 Code => '$o() = $i() + 1;',
                );

          pp_def('tcumul',
                 Pars => 'in(n);[o] mul()',
                 Code => '$mul() = 1;
                          loop(n) %{
                            $mul() *= $in();
                          %}',
          );
          # end example script

If you call this script it should generate output similar to this:

          prompt> perl inlpp.pl
          Inline running PDL::PP version 2.2...
          [1 2 3 4 5 6 7 8 9 10]
[3628800 3628800 3628800 3628800 3628800 3628800 3628800 3628800 3628800 3628800]

You'd need to get the Inline package installed to use this, so you may prefer to stick with makefile's (and I see Jarle has some advice for you there)

Doug

On Feb 26, 2007, at 3:01 PM, Adam Ginsburg wrote:

diagonal is a good case in point. When you do help diagonal in the
perldl shell you will be told that it is defined in Core.pm. This is in
Basic/Core/Core.pm in the PDL source tree. A lot of key functionality
is defined there. However the diagonal (and some other routines) are
defined as simple wrappers around a different function, namely
diagonalI. Here then comes the tricky part.. where is this.

Searching blindly will get you there (something like find . -name
'*.pd' -exec grep -i -H 'diagonalI' {}\;) but who wants to do that each
time. Anyway, first priority is to find a .pd file because these are
the ones that contain the PP definitions you want. And I find that
unless I want to do something hairy I tend to only need to look at two
files for core functionality: Basic/Primitive/primitive.pd and
Basic/Slices/slices.pd - these define many of the most basic functions
and are useful to browse to get some information.

That said, diagonalI is _not_ the function I'd start with if I were
you... In fact, it does sound like given your problem that what you
really want to do is to look at the routines in Image2D/image2d.pd and
ImageND/imagend.pd and get a feel for what you need from these.

Thanks, I did a bunch of fgreps for diagonal but never figured out
exactly where I was supposed to be looking before your comment.  Next
time, I'll use find.

I think the code I'm trying to write might actually be very simple,
something like
pp_def('line_project',
                Pars => 'a(l),float b(), [o]c(l,l);',
                Code => '    int x,y,i;
                                for (i=0;i<$SIZE(l);i++){
                                            y=i*sin(b); x=i*cos(b);
                       $c(x,y)=$a();
                                }'
                                )

probably ought to work, though I don't really know what happens when
you do something like "integer = integer * float" - I'm hoping I get
lucky and it just rounds off nicely =).  I don't know if sin and cos
work that easily.  There's also probably more to be added here
(setting other values to zero, perhaps), but this is a start.

However, I'm having trouble with the Makefile.  When I try to run it,
I get the following error:
Unable to determine UNINSTALLED directory path to PDL::Core::Dev module
but my path to Dev.pm is /usr/local/lib/perl/5.8.8/PDL/Core/Dev.pm .
Was there something I was supposed to do at install time to get this
working that I left out?

Thanks,
Adam

p.s. sorry about the subject of the last post - I'll be more careful
about replying to digests in the future.  I still can't switch out of
digest mode, though.

_______________________________________________
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

Reply via email to