[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: max/min over only one dimension?



Arel Weisberg wrote:
> Is it possible in IDL to find the maximum in each row of a 2-D array
> without a for loop?
> 
> More generally is it possible to find extema in only one dimension of a N
> dimensional array without for loops?

I'll just cite a post to this newsgroup by Craig Markwardt on 18 Mar 1998:

> 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         '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 ].
> 
> Craig
> 
> --
> --------------------------------------------------------------------------
> Craig B. Markwardt, Ph.D.         EMAIL: craigmnet@astrog.physics.wisc.edu
> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
> --------------------------------------------------------------------------

-- 
  Kevin Ivory                           Tel: +49 5556 979 434
  Max-Planck-Institut fuer Aeronomie    Fax: +49 5556 979 240
  Max-Planck-Str. 2                     mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY      http://www.gwdg.de/~kivory2/