Re: [Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Rick Muller
Sweet! Guess I need to learn more about numpy indexing: this is pretty powerful. On Fri, Sep 3, 2010 at 10:42 AM, Keith Goodman wrote: > On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller wrote: > > There just *has* to be a better way of doing this. I want to cut off > small > > values of a vector, an

Re: [Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Keith Goodman
On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller wrote: > 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 lon

[Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Rick Muller
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 lik