PDL::Basic#
PDL’s basic constructors: counting sequences, coordinate values along a dimension, evenly spaced ranges, distances from a centre and histograms.
use PDL;
print sequence(5), " ", sequence(byte, 2, 2)->type, "\n"; # [0 1 2 3 4] byte
print xvals(3, 2)->flat, " ", yvals(3, 2)->flat, "\n"; # [0 1 2 0 1 2] [0 0 0 1 1 1]
print zeroes(4)->xlinvals(0, 1), " ", rvals(3), "\n"; # [0 0.333333333333333 0.666666666666667 1] [1 0 1]
my ($centres, $counts) = hist(pdl(1, 2, 2, 3), 0, 4, 1);
print "$centres $counts\n"; # [0.5 1.5 2.5 3.5] [0 1 2 1]
print zeroes(2, 3)->ndcoords->dims, " ", ndcoords(2)->dims, "\n"; # 223 12
These are upstream’s Perl, unchanged: sequence, xvals, yvals, zvals and axisvals (each element its index along a dimension), xlinvals, ylinvals, zlinvals, xlogvals, ylogvals, zlogvals, axislinvals, axislogvals, allaxislinvals and allaxislogvals (evenly spaced, linearly or logarithmically, between two values), rvals (the distance of each element from the centre), ndcoords (the coordinates of each element), transpose, sec, ins and similar_assign. Each takes dimensions, or an ndarray whose dimensions to use, and an optional type first.
This is PDL::Basic of PDL 2.104. hist is pperl’s own and differs from upstream’s (see the PDL page).