[Numpy-discussion] Cutoff small values of a vector to stop underflow
Fri Sep 3 11:39:13 CDT 2010
There just *has* to be a better way of doing this. I want to cut off small
values of a vector, and I'm currently doing something like:
>>> for i in xrange(n):
>>> if abs(A[i]) < tol: A[i] = 0
Which is slow, since A can be really long. Is there a way to write a Ufunc
that would do something like this more directly? The naive things I've tried
didn't work, e.g.
>>> def cut(a,tol=1e-10):
>>> if less(absolute(a),tol):
>>> a = 0
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion