Blue_eyed_son has asked for the wisdom of the Perl Monks concerning the following question:

Sorry about the vagueness before--I figured you either know it or you don't without explanation.

In the pdl manpages for maximum_n_ind, it identifies the signature as (a(n); int[o]c(m))
This leads me to expect 7 8 9 from this:
$a=sequence(10); p maximum_n_ind($a,3);
But I'm not getting anything. Note:
p maximum_n_ind($a); Returns 9. But any additional argument returns nothing.

Anyone have an example of using this function successfully? I haven't been able to find one, the `signature' listed in the manpages is not helpful, and I can't get it to work playing around. Thanks.

Replies are listed 'Best First'.
Re: maximum_n_ind example
by JadeNB (Chaplain) on Sep 14, 2008 at 03:38 UTC
    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.)

      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.
Re: maximum_n_ind example
by tod222 (Pilgrim) on Sep 14, 2008 at 05:54 UTC
    For this sort of PDL-specific question I've had good luck asking on the perldl mailing list.

    Mailing list archives are available at the above link, too.

      Thanks. JadeNB has it:
      perldl> $c=zeroes(3) perldl> $a=sequence(25) perldl> maximum_n_ind($a,$c) perldl> p $c [24 23 22]
Re: maximum_n_ind example
by broomduster (Priest) on Sep 13, 2008 at 21:51 UTC
    I think you will have better success at getting help if you fill in a few gaps... Like where this function is coming from (right now it's coming out of the blue as far as I can see), which would clue us in to which man pages you are referring to.
      Especially judging from Blue_eyed_son's previous question, I think that it's from PDL (see maximum_n_ind). Unfortunately, I don't know anything about PDL, so I can't understand the linked description (especially since the example usage doesn't seem actually to involve maximum_n_ind); but I think it's meant to give the indices, not just of the least element, but of the least $n elements (where $n is passed in somehow).