What are Piddles?
They are a new data structure defined in the Perl Data Language. As indicated in RFC: Getting Started with PDL (the Perl Data Language):
Piddles are numerical arrays stored in column major order (meaning that the fastest varying dimension represent the columns following computational convention rather than the rows as mathematicians prefer). Even though, piddles look like Perl arrays, they are not. Unlike Perl arrays, piddles are stored in consecutive memory locations facilitating the passing of piddles to the C and FORTRAN code that handles the element by element arithmetic. One more thing to note about piddles is that they are referenced with a leading $
Now, given two piddles ($piddle1 and $piddle2) of the same size, this snippet shows you how you can easily compose operations in which the first operation is applied on an element by element basis. In this particular example, I was interested in finding the sum of the smaller elements. For the first operation, I used the minimum and for the second one, I used the sum. Note that for the first operation there are several options available (depending on what you want to do), such as minimum, maximum, average, and medover. For the second operation there are also several options available (depending, of course, on what you want to do), such as sum, prod, max, and min. For a more complete list of operations, please have a look at RFC: PDL Cheat Sheet.
- Added the definition of piddle. Thanks blazar for the suggestion