# PDL::Ufunc
📦 stdpdl
Unary reductions and aggregations over PDL arrays. This module holds
every operation that collapses one or more dimensions of a piddle
down to a summary — sums, products, means, extrema, percentiles,
sort-based reductions, and cumulative variants.
These are the first functions most users reach for. They behave
the same on 1-D arrays as on higher-rank arrays, and they all share
a consistent story about bad values, type promotion, and when they
reduce everything vs. just one axis.
## Synopsis
```none
use PDL;
my $a = pdl [1, 2, 3, 4, 5];
print $a->sum, "\n"; # 15
print $a->avg, "\n"; # 3
print $a->min, "\n"; # 1
print $a->max, "\n"; # 5
```
## Functions
### Full-array reductions
#### [`sum`](Ufunc/sum.md)
Add up every element of a PDL and return the total as a 0-dimensional PDL.
### Other Functions
#### `qsortvec`
`qsortvec($pdl)` — sort rows of a 2D pdl lexicographically, return sorted data.
#### `qsortveci`
`qsortveci($pdl)` — sort rows of a 2D pdl lexicographically, return index piddle.
#### `minimum_n_ind`
`minimum_n_ind($pdl, $n)` — 3-arg c2rust: (a, c, m_size)
#### `maximum_n_ind`
`maximum_n_ind($pdl, $n)` — 3-arg c2rust: (a, c, m_size)
#### `pctover`
`pctover($pdl, $pct)` — 3-arg c2rust: (a, p, b) where p is pct as a scalar pdl `pctover($pdl, $percentile)` — Excel/NIST linear-interpolation percentile. Mirrors `Ufunc.pd` pp_def(“pctover”) algorithm: rank = 1 + p\*(n-1); interp between sorted[floor(rank)-1] and sorted[ceil(rank)-1]. The c2rust version produces rounding errors on the boundary (17.0000000007 != 17); this pure-Rust path avoids the double→double→double chain and is bit-exact when the interpolation happens on aligned indices.
#### `all`
`all($pdl)` — 1 if all elements nonzero, via full andover reduction
#### `any`
`any($pdl)` — 1 if any element nonzero, via full orover reduction
#### `minmax`
`minmax($pdl)` — return a 2-element list: (min_value, max_value). Iterates all elements via pdl_at_flat, tracking min and max.
#### `pct`
`pct($pdl, $p)` — percentile, delegates to pctover then extracts scalar. Returns a 0-d PDL scalar.
#### `oddpct`
`oddpct($pdl, $p)` — odd percentile (nearest-rank method). Sort the data, return element at index floor((n-1) \* p). Returns a 0-d PDL scalar.
#### `stats`
`stats($pdl)` — compute 7 summary statistics. Returns (`$mean`, `$prms`, `$median`, `$min`, `$max`, `$adev`, `$rms`).