Skip to contents

Symbolic element-wise sign operation for LazyTensor objects or default element-wise sign operation otherwise.

Usage

sign(x)

Arguments

x

input for sign.default() or sign.LazyTensor().

Value

See value of sign.default() or sign.LazyTensor().

Details

If x is a LazyTensor, see sign.LazyTensor(), else see sign.default().

The sign function is defined as follows: $$\text{sign}(x) = \left\{ \begin{array}{rcl} 0 & \text{if } & x = 0\\ -1 & \text{if } & x < 0\\ 1 & \text{if } & x > 0 \end{array}\right.$$

Author

Chloe Serre-Combe, Amelie Vernay

Examples

if (FALSE) {
# R base operation
sign(5)
sign(-5)
sign(-10:10)
# LazyTensor symbolic element-wise sign
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i')   # creating LazyTensor from matrix x, 
                                    # indexed by 'i'
Sign_x <- sign(x_i)                 # symbolic matrix, 150 rows and 3 columns
}