in reply to PDL Command: maximum_n_ind example

As far as I can tell from this documentation on signatures, the second slot is for an object that will receive the output. I suppose that, if you pass in a length-3 array (or whatever output object is appropriate), then it'll get the elements you want; whereas, if you pass in the constant 3 as the second argument, it tries to stuff the output into that constant, with results that are presumably nonsensical at best.

As ikegami mentioned, this function doesn't seem to exist in the latest version of PDL (see particularly PDL::Primitive). Unless you're stuck with an older version, or have a reason to prefer it, then it's probably a good idea to work with the latest one. (Also, it might be a good idea to put something more prominent about PDL in your main post, so that future readers don't have to dig down several levels in the comments to find out what we're discussing.)

Replies are listed 'Best First'.
Re^2: maximum_n_ind example
by etj (Priest) on Jun 06, 2022 at 01:06 UTC
    maximum_n_ind lives in PDL::Ufunc (somewhat to my surprise). To find this sort of information, in perldl do:
    pdl> ?? maximum_n_ind maximum_n_ind P::Ufunc Returns the index of `m_size' maximum elemen +ts. As of 2.077, you can specify how many by either pa +ssing in an ndarray of the given size (DEPRECATED - w +ill be converted to indx if needed and the input ar +g will be set to that), or just the size, or a null an +d the size. maxover_n_ind P::Ufunc Synonym for maximum_n_ind.