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

Home » Public Forums » archive » Re: JBIU utilities - release 1.0
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: JBIU utilities - release 1.0 [message #60793] Fri, 13 June 2008 13:58 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mgalloy@gmail.com writes:

> Or a lesson on why open source software can produce robust code.

Oh, I know it can produce better code. But when you add
in the psychologist's fees, I'm not sure it's any cheaper. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: JBIU utilities - release 1.0 [message #60794 is a reply to message #60793] Fri, 13 June 2008 13:54 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Jun 13, 12:45 pm, David Fanning <n...@dfanning.com> wrote:
> Let this be a lesson to all the folks out there who think
> writing code for public consumption is a barrel of laughs!

Or a lesson on why open source software can produce robust code.

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
Re: JBIU utilities - release 1.0 [message #60796 is a reply to message #60794] Fri, 13 June 2008 13:07 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Jun 13, 12:44 pm, Brian Larsen <balar...@gmail.com> wrote:
> Oddly I opened up sign() and in the spirit of Coyote's IDL way I have
> previously written sign() without the nasty for loop. This rewrite
> gained a x12.6 improvement in speed for my test case.
>
> function sign, in
> pos = make_array(n_elements(in), /byte, value = 1)
> zero = in EQ 0
> neg = in LT 0
> pos = pos - zero
> pos = pos - 2 * neg
> return, pos
> END

Yup, that would definitely be better! You can probably age date when I
originally wrote each of those routines by the decreasing number of
FOR loops with time. ;-)

-Jeremy.
Re: JBIU utilities - release 1.0 [message #60797 is a reply to message #60796] Fri, 13 June 2008 13:03 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
Always goes to show that there is a better way :)

I find yours is 1.6 times faster than mine (from the one test I ran).
And uses a lot less memory.


Cheers,

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
Re: JBIU utilities - release 1.0 [message #60802 is a reply to message #60797] Fri, 13 June 2008 11:45 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mgalloy@gmail.com writes:

> How about the following?
>
> function mg_sign, x
> compile_opt strictarr
>
> return, fix(x gt 0) - fix(x lt 0)
> end

Let this be a lesson to all the folks out there who think
writing code for public consumption is a barrel of laughs!

Cheers,

David

P.S. Let's just say most of us do our best thinking
*after* we hit the SEND button. :-(

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: JBIU utilities - release 1.0 [message #60803 is a reply to message #60802] Fri, 13 June 2008 11:39 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Jun 13, 10:44 am, Brian Larsen <balar...@gmail.com> wrote:
> Oddly I opened up sign() and in the spirit of Coyote's IDL way I have
> previously written sign() without the nasty for loop.  This rewrite
> gained a x12.6 improvement in speed for my test case.
>
> function sign, in
>     pos = make_array(n_elements(in), /byte, value = 1)
>     zero = in EQ 0
>     neg = in LT 0
>     pos = pos - zero
>     pos = pos - 2 * neg
>     return, pos
> END

How about the following?

function mg_sign, x
compile_opt strictarr

return, fix(x gt 0) - fix(x lt 0)
end

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
Re: JBIU utilities - release 1.0 [message #60808 is a reply to message #60803] Fri, 13 June 2008 09:44 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
Jeremy,

thanks for putting this on the web. I always like "borrowing" code
instead of rewriting it and there is some good stuff there.

Oddly I opened up sign() and in the spirit of Coyote's IDL way I have
previously written sign() without the nasty for loop. This rewrite
gained a x12.6 improvement in speed for my test case.

function sign, in
pos = make_array(n_elements(in), /byte, value = 1)
zero = in EQ 0
neg = in LT 0
pos = pos - zero
pos = pos - 2 * neg
return, pos
END



Cheers,

Brian


------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
Re: JBIU utilities - release 1.0 [message #60918 is a reply to message #60803] Sun, 15 June 2008 15:30 Go to previous message
MP is currently offline  MP
Messages: 15
Registered: March 2006
Junior Member
On Jun 13, 12:39 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
>
> How about the following?
>
> function mg_sign, x
>   compile_opt strictarr
>
>   return, fix(x gt 0) - fix(x lt 0)
> end

Prior art! :)

http://www.ittvis.com/codebank/search.asp?FID=296

(Just kidding, Mike; I'm sure someone thought of this long before I
did.)

mp
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Warping with intensity conservation or drizzle algorithm
Next Topic: JBIU utilities - release 1.0

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

Current Time: Wed Oct 08 15:13:26 PDT 2025

Total time taken to generate the page: 0.00677 seconds