next up previous contents
Next: Solution Up: Arrays Previous: Solution

 

Vector Subscripts / MAXLOC

Generate an arbitrary 1D array, vector, filled with random numbers between 0 and 1. By usingthe MAXLOC intrinsic with a suitable mask set up an integer array, VSubs, which contains a permuted index set of vector such that Vector(VSubs(i)) > Vector(VSubs(i+1)) for all valid i.

You may find it useful to use the MAXLOC intrinsic. For example,

    MAXLOC(VSubs)

returns an array containing the index of the largest element of the array VSubs, and,

    MAXLOC(VSubs,MASK=VSubs.LT.VSubs(i))

returns the position of the largest element that is less than the value of VSubs(i). In both cases the result is a one element 1D array. (The array contains one element because VSub only has one dimension.)




next up previous contents
Next: Solution Up: Arrays Previous: Solution

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 14:10:26 GMT 1996