comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Need efficient routine to calculate max of two arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Need efficient routine to calculate max of two arrays [message #3410 is a reply to message #3402] Thu, 26 January 1995 06:25 Go to previous messageGo to previous message
pa64 is currently offline  pa64
Messages: 3
Registered: January 1995
Junior Member
In article <3g3p8i$1o6@cobra.aer.com>, gallery@aer.com (William O. Gallery) writes:
|> Here is the problem:
|>
|> There are two arrays: a and b of equal length, I want to calculate
|> an array c of the same length so that:
|> c(i) = min(a(i),b(i))
|>
|> For efficiency, I want to use vectors and not a do loop.
|>
|> Any suggestions? This would seem to be a common enough problem,
|>
|>
|>
|> --
|> William O. Gallery gallery@aer.com
|> Atmospheric & Environmental Research Voice(617) 349-2284
|> 840 Memorial Drive (617) 547-6207
|> Cambridge, Massachusetts 02139 FAX (617) 661-6479

Up to four arrays, the following function seems to be quite efficient:

function pmin,im1,im2,im3,im4
if n_params() gt 3 then begin
index = where(im4 lt im3, count)
if count gt 0 then im3(index) = im4(index)
endif
if n_params() gt 2 then begin
index = where(im3 lt im2, count)
if count gt 0 then im2(index) = im3(index)
endif
if n_params() gt 1 then begin
index = where(im2 lt im1, count)
if count gt 0 then im1(index) = im2(index)
endif
return,im1
end


Regards,
Hermann Mannstein


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Hermann Mannstein Tel.: +49 8153 28-2503
Institut fuer Physik der Atmosphaere or -1118
DLR - Oberpfaffenhofen Fax.: +49 8153 28-1841
Postfach 1116 email.: H.Mannstein@dlr.de
D-82230 Wessling \
Germany \ O
________\/|________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`--------\--------'~ ~~~~~~~~~~~~~~~~~~~~
\
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: emacs and IDL (typos in URLs)
Next Topic: floating pt. sliders....

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:33:43 PDT 2025

Total time taken to generate the page: 1.11810 seconds