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

Home » Public Forums » archive » 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
SIGN function: signof(num or array of num) [message #70155] Tue, 16 March 2010 03:51
Ding is currently offline  Ding
Messages: 20
Registered: March 2008
Junior Member
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

Ding Yuan
Ding.Yuan@warwick.ac.uk
PhD
Center for Fusion,Space and Astrophysics
Department of Physics
University of warwick


function signof,input
;+
; NAME:
; signof
;
; PURPOSE:
; 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
; CATEGORY:
; maths
;
; CALLING SEQUENCE:
; signof(input)
; INPUTS:
; scalar,vector, or array
;
; OPTIONAL INPUTS:
; None
;
; KEYWORD PARAMETERS:
; None
;
;
; OUTPUTS:
; the same size of the input but in integer
;
; OPTIONAL OUTPUTS:
; None
;
; COMMON BLOCKS:
; None
;
; SIDE EFFECTS:
; none
;
; RESTRICTIONS:
; none
; EXAMPLE:
; a=[[1,-2],[0,3]]
; print, signof(a)
; 1 -1
; 0 1
;
; MODIFICATION HISTORY:
; 2010-02-09Writen by Ding Yuan (Ding.Yuan@warwick.ac.uk)
; CFSA, Dept. of Physics, University of Warwick
;
; The author should be notified if modifications are made
;-
return, fix(abs(input)/input)

end
[Message index]
 
Read Message
Previous Topic: Find out which area is covered in a map plot
Next Topic: Re: IDL out of range error

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

Current Time: Wed Oct 08 20:13:27 PDT 2025

Total time taken to generate the page: 0.01220 seconds