Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

david m (9460)

david m
  (email not shown publicly)

I am a graduate student in Physics at the University of Illinois where I study synchronization and other nonlinear stuff. I play around with Perl and PDL when not working, running, or visiting my fiance.

Journal of david m (9460)

Sunday October 25, 2009
12:01 AM

PDL 2.4.5 is just released, and here's how to install it

[ #39799 ]

Chris Marshall has recently released PDL v2.4.5, a stepping-stone in the Perl Data Language. Chris has led the charge to get cross-platform OpenGL support for PDL. In the past, PDL has used its own GL code, but with Chris's work it now uses Perl's Open GL module, affectionately known as POGL.

You can install PDL from the CPAN without any manual work. However, you'll be missing a lot of goodies, like plotting, OpenGL, and the GSL. In this journal entry, I go through the steps necessary to get PDL installed and working, goodies and all.

The Perl Data Language is a language extension that adds number-crunching and numerical array capabilities to Perl that is on par with C in terms of speed and memory consumption. If you are familiar with IDL or Matlab, think of this as Perl's extension that makes it work essentially like either of those. Having these numerical capabilities is good, but the project is quite complicated and some manual work is probably necessary to get PDL to work the way you'd like. That's what I'll discuss here. I will perform this tutorial using my cpan shell, but hopefully the instrucitons I give will be decent enough that you can perform the installation manually if you cannot use cpan.

Note to ActiveState Perl users: sisyphus (one of the PDL developers/users) has created ppm packages for PDL. I have appended a comment with details, so if this is you, scroll down to the bottom of the page.

Step 0: Install Perl's OpenGL dependencies. The OpenGL module requires freeglut. If you're using Strawberry Perl on Windows, you don't have to do this because POGL (Perl's OpenGL) will download everything it needs. If you're on Linux, you'll need to check your flavor's package manager for it's library or get it from Sourceforge.

Step 1: Install Perl's OpenGL module. You should be able to get this on cpan without trouble by issuing:

get OpenGL
make OpenGL
test OpenGL
install OpenGL

If you run into trouble, look at the INSTALL file by typing look OpenGL in cpan and then examining the file. Hopefully a few manually issued commands will solve your problem.

If you don't use cpan, you can still get the tarball from cpan's web page. If you download the tarball, you'll need to unpack it somewhere, open a command prompt in the unpacked directory, and issue the following commands:

perl Makefile.PL
make
make test
make install

The last command will probably have to be run with root privileges.

Note that on some platforms, you may need to replace make with a similarly named utility. I believe it's dmake for Strawberry Perl. If it's not, you probably know who you are and what it's called. I'm sure Google can help. (If you've got ActiveState's Perl, there's a PPM discussed in the comments at the bottom of this post.)

Step 2: Check out the new PDL code (but don't install yet!). From the cpan shell, simply type get PDL. If cpan is not available to you, you can download the source code from cpan's web page for PDL or from sourceforge. Either way, you'll get a tarball that you'll have to open up somewhere.

Step 3: Take care of the prerequisites. As long as you've got a C compiler, PDL should work out-of-the-box. However, you can enable a great deal of optional functionality by ensuring you've got a few dependencies installed. To figure out what these dependencies are, go to the directory containing the (untarred) distribution (in cpan, you do that by typing look PDL) and examine the DEPENDENCIES file. Make a list of the various dependencies that you'll have to install. I recommend installing these before you install PDL. Here's an overview of the dependencies that I deem important. To read about all of the dependencies, check out the DEPENDENCIES file. If you have any questions about dependencies I don't discuss here (or about stuff I do discuss here, for that matter), you can send a query to the PDL mailing list, which you can find here.

Term::ReadLine
Makes your PDL shell a more pleasant experience
OpenGL
Already discussed - needed for OpenGL stuff
PLplot
This is useful for 2D plotting (which I hope to write about some time in the not-so-distant future). You'll need the PLplot libraries, which you can hopefully install for your system with your package manager; otherwise you can get them from sourceforge.

(I had GSL and FFTW2 on this list, but it turns out that PDL has its own FFT implementation and does not need FFTW2, and I'm not sure that GSL should come so highly recommended. Don't get me wrong - it's a great library and I've used it before, but I think it would be more appropriate to install it only if you'll actually use it. Don't worry: if you use either of these libraries, you'll have it installed and PDL should detect it and compile the PDL bindings for it.)

Remember: PDL has many other optional features that have their own prerequisites, such as SLATEC and Minuit. Please check the DEPENDENCIES file for details on what's available and what it requires.

Step 4: Install PDL. Now that you've got all the prerequisites out of the way, go ahead and install PDL. You can use the same commands you used when you installed POGL above. If you run into trouble here, take a look at the perldl.conf file, which will allow you to tweak the installation process a bit more to your liking.

The build process can take a while, but you'll want to pay attention. The process automatically detects various libraries. This is particularly important if it misses an important library for you, in which case you will probably need to tweak the perldl.conf file. The file has lots of internal self-documentation so hopefully you'll be able to figure out what to try to fix your problem. However, if you run into trouble, check out the BUGS file for instructions on how to report bugs or other trouble to the PDL developers.

Step 5: Learn more about PDL. The documentation for PDL isn't great for beginners, but it gets the job done. Check out the wiki, which not only has documentation for PDL but also has links to some good external documentation. If you find some feature to be somewhat under-documented, please let me know and I'll try to tackle it some time in one of my journals. Then, hopefully, I'll propagate the documentation back to the wiki and the POD files.

I hope this helps those of you who have been curious about PDL but have not put in the effort to get it to work. If you have any questions, the readers of the PDL mailing list are usually happy to help. Check here for those email addresses.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I've been meaning to learn more PDL so I can do a quick intro for the students in my department. Mostly as an alternative to Matlab.

    I just haven't made the time to learn it and really the plotting part. I think that's what sets matlab apart is the plotting. An ex-grad student did a similar thing with Python (which I might try to pick up but my Python Fu is weak, as it usually is for Perl folks).

    Keep the posts coming, you'll have one interested reading.

  • Every time someone says "No no no no, unlike the rest of CPAN, this one has to be installed by a human" I want to avoid those modules, because if that's the case how will I ever embed that thing in something larger, such that the person installing the larger thing doesn't need to know anything about how it works underneath.

    • Sure, that's fair. I'm afraid I didn't really stress that you can install PDL from CPAN without doing anything special that I discussed above. (I've edited my original post to reflect this.) PDL's installer will detect if you've got OpenGL or PLplot installed, and skip those steps if it doesn't find it. You really only need to do the special stuff if you want to visualize your data or use the GSL.

      You do raise an important point, of course. Suppose you wanted to write a module or program that uses PDL t

    • Ha! So I just read what you had to say about Chocolate Perl [perl.org]. So you are quite serious when you say you're thinking about including PDL in a bigger project...

      As I said, it works out-of-the-box from CPAN. I've dropped a note on the Perldl mailing list about making the installer even smarter, but since a lot of optional PDL stuff depends on external libraries, it would be nice to have some way to interact with the OS and make it install its version of the desired library.

  • For those of you using ActiveState's ppm, detailed instructions are given in the tarball's win32/INSTALL file. Since you probably won't have much use for said tarball, I've included the lowdown here. If you need more details... I guess you'll have to downlaod that tarball and take a look at the file yourself.

    First up install Astro::FITS::Header by running:

    ppm install Astro-FITS-Header

    Then install the OpenGL, PGPLOT and PDL modules from the uwinnipeg rep by running:

    For perl 5.8:
      ppm install http:/