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

Home » Public Forums » archive » 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 #6439 is a reply to message #6323] Tue, 11 June 1996 00:00 Go to previous messageGo to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <4pcm41$64r@vixen.cso.uiuc.edu>, santanu@glibm5.cen.uiuc.edu (S Bhattacharyya) writes:
|> 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 ?
|>

Q2 can actually be solved without loops, quite fast
(if I've understood your question correctly)

foo = rebin(findgen(1,b),a,b,/sample)

The "solution" to Q1 is that the "array reduction" operations min/max
(and others!) should get the same functionality as TOTAL, where you can
choose which dimension to total over. If you have a MAX() like that, you
could use something like (foo = foo(a,b))

foo = foo / rebin(reform(max(foo,2),a,1),a,b,/sample)

or perhaps (to save some space):

maxfoo = max(foo,2) ;; Max along each column
foo = temporary(foo) / rebin(reform(maxfoo,a,1),a,b,/sample)

Stein Vidar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Searching for Constraint Optimization IDL Routine
Next Topic: Re: polar surfaces

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

Current Time: Sat Oct 11 08:39:26 PDT 2025

Total time taken to generate the page: 0.24134 seconds