|
Contents | Previous | Next | Subchapters |
| Syntax |
nozero(x, bound) |
| See Also | sign |
/ x if |x| > bound
nozero(x) = {
\ sign(x) bound 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.
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 ]