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

Home » Public Forums » archive » [Q]: ID analog to FORTRAN "sign" function
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: [Q]: ID analog to FORTRAN "sign" function [message #21989 is a reply to message #21932] Thu, 12 October 2000 13:50 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Dick Jackson" <dick@d-jackson.com> wrote in message
news:8MkF5.12$953.172@read1...
> Do I dare offer one more? Subscript lookups seem faster than arithmetic
> operations, making this one faster, more compact and no less cryptic! :-)
>
> Return, Abs(a) * ([-1, 1])[b GE 0]

Good one!

> A bit faster still, if you know the expected type of a and b, to avoid an
> extra type conversion:
>
> Return, Abs(a) * ([-1.0, 1.0])[b GE 0]

I think that's a little *too* clever. I just tried multiplying a float array
with 10^7 elements by 1 and then by 1.0. Time taken = 0.52 seconds in both
cases.

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 3D Visualization
Next Topic: Re: BINARY FILES

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

Current Time: Fri Oct 10 11:04:38 PDT 2025

Total time taken to generate the page: 0.96416 seconds