Contents Previous Next Subchapters

Replaces Zero By a Small Value
Syntax nozero(xbound)
See Also sign

Description
Returns the element-by-element value
                  / x              if |x|  > bound
     nozero(x) = {
                  \ sign(xbound  if |x|  < bound
where sign(x) is the sign of the corresponding element of x (interpreted as 1 when x is 0).

This function can be used to avoid division by 0 when x is used as an element-by-element divisor.

Example
     x     = [-.1, -.01, -.001, 0., .001, .01, .1]
     bound = .002
     nozero(x, bound)
returns
     [-0.1 , -0.01 , -0.002 , 0.002 , 0.01 , 0.1 ]