Interesting problem and discussion. I have little to add to what has already been said, but wanted to note that a solution to the problem of finding the index of the minimum in an array is conveniently implemented in Perl Data Language (PDL) with the minimum_ind function.
From the manual:So, in principle, assumming you already have an array @array you could do:Module PDL::Ufunc minimum_ind Signature: (a(n); indx [o] c()) Like minimum but returns the index rather than the value Output is set bad if all elements of the input are bad, otherwise +the bad flag is cleared for the output piddle.
use PDL; my $piddle = pdl @array; my $index_minimum = minimum_ind $piddle; say $index_minimum;
You could try to reduce your problem so you can use a minimum_ind approach, for example, if you have negative numbers you could convert them to NaN or take abs and make them positive, whatever is important or relevant in your context.
In reply to Re: How to get the index of smallest whole number in an array?
by hda
in thread How to get the index of smallest whole number in an array?
by sohamsg90
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |