Contents Previous Next Subchapters

The Sign Function
Syntax sign(x)
See Also ordered comparisons

Description
Returns the element-by-element value 1 for each non-negative element and -1 for each negative element of x, where x is an integer, real, or double-precision matrix.

Example
     sign([-3, 4, 0])
returns
     [ -1 , 1 , 1 ]

Mlmode
In Mlmode , the sign function accepts complex arguments and returns x ./ abs(x) in this case. In addition, it returns zero if the argument if the argument is equal to zero. If in Mlmode you enter
     sign( [ 0*i , 1*i , 2*i ] )
O-Matrix will respond
     [ (0,0) , (0,1) , (0,1) ]