Finding a maximum in an array

Timothy Cullip cullip at sargent.cs.unc.edu
Thu Sep 27 22:22:20 AEST 1990


Thanks for all who responded to my posting about searching for
the maximum element in an array.  It looks like ISMAX() from
LIBSCI is a good choice for general use.  The only problem I
had was that it took me a minute to remember that FORTRAN uses
arrays starting with index 1 and C uses index 0, but after
accounting for that it worked.

It turns out though for the type of data arrays I am searching
(very long - up to a million elements, and having the maximum
near the middle with lots of generally increasing and generally
decreasing sections) my routine consistently beat ISMAX() by
about 50%.

Thanks again for all the responses (about 20), it's encouraging
to know there are a lot of willing and knowledgable people out
there.  Like I said, I'm a Cray novice (I didn't even know about
LIBSCI) - so I learned something.

   Tim Cullip



More information about the Comp.unix.cray mailing list