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:
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.
So, in principle, assumming you already have an array
@array you could do:
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.