Finding the Max/Min of Row/Col of an IDL Array

QUESTION: Is it possible to find the maximum (or minimun) in each row (or column) of a 2D array without using a FOR loop?

ANSWER: This answer was provided by Craig B. Markwardt on the IDL newsgroup in response to a question about finding the sum of a selected dimension of a multi-dimensional array.

I have also had the need for totalling over selective dimensions (sometimes more than one dimension), and also MIN/MAX.

Check out my IDL web page for CMAPPLY(), which can apply quite a number of operations to selected dimensions of an array. You can do this to more than one dimension at a time using a *list* of dimensions (similar to the DIMENSIONS parameter to MAKE_ARRAY or to REFORM).

http://astrog.physics.wisc.edu/~craigm/idl/idl.html

CMAPPLY supports more than just addition; it does:

   (+)   addition,        (*)   multiplication,
   (AND) logical AND,     (OR)  logical OR,
   (MAX) maximum, and         (MIN) minimum.
  

Where possible I avoid loops to improve performance, but your mileage may vary depending on the detailed use. (For example, for small arrays, your own loop may be faster).

Google
 
Web Coyote's Guide to IDL Programming