Just to add to Rahman's answer, for some specific situations there might be faster options than which or where (see help where - I often find that where is the more efficient but it depends on what you need). For instance if you require the maximum/minimum and the location then the function you want is probably minmaximum (yes, the name isn't the best).

It does get you the maximum and minimum values as well as the indices. Since this is all done in one pass it will require 1/2 (roughly) the time of a first call to max and then a call to which. I say roughly because there is a tad more overhead in minmaximum than in max.

                                        Cheers,
                                                Jarle.



On 11 Dec 2007, at 00:21, <[EMAIL PROTECTED]> wrote:

Hi,

I have searched the documetation and came up empty on this one. Is there a PDL function that will return the position of a value within a piddle ? For example: I search for the maximum value within a one-dimensional vector:

$x is a 1-D piddle

$max = max($x);

$max will contain the largest value from $x. Is there a way to find out what it's position is within $x without copying the PDL vector to a perl list and looping ?

Rai

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to