PDL Object Constructors
When using PDL one creates and manipulates PDL object, whimsically called piddles. These objects represent an array of arbitrary dimensionality and unlike most of Perl, of a certain numerical datatype.
A PDL object may be created using the
which converts a Perl array structure to a PDL.
my $pdl = pdl([[1,2,3],[4,5,6],[7,8,9]]);
To see what the PDL object contains, since PDL overloads stringification, simply print it out. To get other information, the
info method is also useful.
my $pdl = pdl([[1,2,3],[4,5,6],[7,8,9]]); say $pdl; say $pdl->info;
Many of the other PDL contstructor functions take the dimensionality as their argument. For example
sequence creates a PDL whose values increment for each element.
# create a 5x5 PDL my $pdl = sequence 5,5; say $pdl;
Other such constructors are
rvals. The first two are obvious, creating a PDL filled with 0 or 1. The next three create a PDL of a given dimensionality, but whose values are taken from their x, y, or z component respectively.
rvals creates a PDL whose values are the "distance" from the center of the PDL (or whichever other center you specify).
Create a three dimensional PDL using any of the above constructors and print out its information using the
my $pdl = ...; say $pdl->info;