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

Home » Public Forums » archive » Re: Can I do this without using loops?
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: Can I do this without using loops? [message #6301] Sat, 08 June 1996 00:00 Go to previous message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
In article <4pcm41$64r@vixen.cso.uiuc.edu>, santanu@glibm5.cen.uiuc.edu (S
Bhattacharyya) wrote:

> Regarding loops, I am kinda in the same boat. My advisor
> keeps complaining about how slow our code runs...We don't seem to
> know any better around here :-)
>
> Q1) I have a generic array foo(x,y). I'd like to divide each column
> by its max. Can this be done without looping ?
>
> Q2) I have a generic array foo=fltarr(a,b). I'd like to copy findgen(b)
> into every column. Any way of doing this without loops ?

It is always the *innermost* loop that you need to worry about. Of course
you want to avoid taking large strides in memory in the innermost loop, as
well as using array syntax. A2 (below) should run very fast. I'm using
the first quadrant convention for subscripts (i.e., (i,j) corresponds to
(x,y), so to me a column is the second subscript. You may need to reverse
that.

A1)

FOR i = 0, ni-1 DO foo(i,*) = foo(i,*)/MAX(foo(i,*))

A2)

FOR j = 0, nj-1 DO foo(*,j) = FLOAT(j)

Regards, Ken Bowman

--
Kenneth P. Bowman, Assoc. Prof. 409-862-4060
Department of Meteorology 409-862-4132 fax
Texas A&M University bowman@csrp.tamu.edu
College Station, TX 77843-3150
Satellite ozone movies on CD-ROM --> http://www.lenticular.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Call_External and the C Math Library
Next Topic: Re: another composite image question

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

Current Time: Fri Oct 10 06:24:01 PDT 2025

Total time taken to generate the page: 1.60106 seconds