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

Home » Public Forums » archive » Re: SIGN function: signof(num or array of num)
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: SIGN function: signof(num or array of num) [message #70137 is a reply to message #70136] Tue, 16 March 2010 08:43 Go to previous messageGo to previous message
Ding is currently offline  Ding
Messages: 20
Registered: March 2008
Junior Member
On Mar 16, 10:51 am, Ding <gardener_2...@hotmail.com> wrote:
> Dear IDL users,
>
> I cannot find the SIGN function in IDL procedures, but one in
> Solarsoft ssw/maths/ SIGN which occupy the name, but different
> purpose( sign(a)*b). so I wrote the SIGNOF() function which is to get
> the sign of a number or array,
>
> Hopefully I am not repeating someone' work! you are welcome to
> comments!
>
> ;    return the sign of the input data in an array of the same size
> ;    -1 for negative elements
> ;    1 for positive elements
> ;    0 for 0 and complex number
> ;    only works for numerics

return the sign of the input data in an array of the same size
-1 for negative elements
1 for positive elements
0 for 0 and complex number
only works for numerics
>a=[[1,-2],[0,3]]
> print, signof(a)
1 -1
0 1
>
More notes:

although signof(0) cause algorithm error, since 0/0 is defined as 0,
signof(0)=0, signof(Inf)=0. it can be used in an expression
signof(numeric variable or array)*10.0/5. etc.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to read data with format codes?
Next Topic: Predefined iTool Visualization in existing iTool

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

Current Time: Sat Oct 11 15:13:08 PDT 2025

Total time taken to generate the page: 1.52262 seconds