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

Home » Public Forums » archive » Re: Can I de-loop?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Can I de-loop? [message #16298] Thu, 15 July 1999 00:00
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
Bested yet again. Bob's answer seems to run about 50% faster than my
solution for a large number of elements. Good answer Bob and thanks!!

David, you can keep your job. I could conceivably work FOR you but I
don't think I would want to work AS you. You do way more for this
community than any mortal person should do. (not that I want you to
quit) :-)

Cheers,
eddie

----- ---- --- --- ---- --- -- --- --- -- -- - - - -
|\ A G Edward Haskell
|\ Center for Coastal Physical Oceanography
|\ Old Dominion University, Norfolk VA 23529
|\ Voice 757.683.4816 Fax 757.683.5550
|\ e-mail haskell*ccpo.odu.edu
----- ---- --- ---- --- --- --- --- -- -- -- - - - -
Re: Can I de-loop? [message #16301 is a reply to message #16298] Thu, 15 July 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Eddie Haskell (haskell@see.signature.edu) writes:

> You should check this thread later as I should point out that over 95%
> of my suggestions to this newsgroup do not end up helping the original
> question. Either my solution is too specific for the problem or someone
> else soon posts a better solution.

Oh, well. You should try putting this stuff on a web page. :-(

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Can I de-loop? [message #16302 is a reply to message #16298] Thu, 15 July 1999 00:00 Go to previous message
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
I have a suggestion for the first of your quandries:

> a) I am adding a constant amount K to several elements N of array A.
> The elements Ni are not unique; if an Ni is repeated, I want to add it
> to A each time. For instance, given
>
> A = [0,1,2]
> N = [2,2,2]
> K = 4
>
> I want the result A = [0,1,14], not A = [0,1,6]

IDL> A[min(N):max(N)] = A[min(N):max(N)] + K*histogram(N)
IDL> print,A
0 1 14

This seems to be at least twice as fast as the loop with the time
difference increasing as the number of elements in A and N increase, at
least for the values I played around with ( up to 100,000 elements).

You should check this thread later as I should point out that over 95%
of my suggestions to this newsgroup do not end up helping the original
question. Either my solution is too specific for the problem or someone
else soon posts a better solution. I hope for the latter as I can also
learn something that way.

Cheers,
eddie

----- ---- --- --- ---- --- -- --- --- -- -- - - - -
|\ A G Edward Haskell
|\ Center for Coastal Physical Oceanography
|\ Old Dominion University, Norfolk VA 23529
|\ Voice 757.683.4816 Fax 757.683.5550
|\ e-mail haskell*ccpo.odu.edu
----- ---- --- ---- --- --- --- --- -- -- -- - - - -
Re: Can I de-loop? [message #16305 is a reply to message #16298] Thu, 15 July 1999 00:00 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
In article <7mje9s$263$1@nnrp1.deja.com>,
throop@colorado.edu wrote:>For instance, given
>
> A = [0,1,2]
> N = [2,2,2]
> K = 4
>
> I want the result A = [0,1,14], not A = [0,1,6]


I'll take this one guys (using the non-gender-specific meaning!).
Woohoo! My first "use histogram" posting!


A = [0,1,2]
N = [2,2,2]
n = n(sort(n)) ; you may need this, not sure of your application
K = 4

print,a
a =a+k*histogram(n,binsize=1,min=0,max=n_elements(a)-1)
print,a

This may not be general enough for your application, but
you get the idea. Always use histogram if possible.

Cheers,
bob




Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Too many users...
Next Topic: Boundary Finding (Edge Enhancement)

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

Current Time: Wed Oct 08 19:12:24 PDT 2025

Total time taken to generate the page: 0.00561 seconds