[SciPy-user] Faster allclose, comparing arrays

Tom Johnson tjhnson at gmail.com
Fri Apr 4 14:54:58 EDT 2008


On Sat, Feb 2, 2008 at 12:36 PM ...
>  For a more subtle example, suppose you want to compare a vector and a
>  result obtained by Fourier transforming. If your vector is something
>  like [1,2,3,4] allclose() will do pretty much what you want. But if
>  your vector is something like [1e40,0,0,0], you might have a problem:
>  the Fourier transform can be expected to introduce numerical errors in
>  all the components of size about machine epsilon times the *largest
>  component*. Since allclose() does an element-wise comparison, if you
>  get [1e40+1,1,1], allclose returns False when the answer is true to
>  numerical accuracy. On the other hand, sometimes the different
>  elements of a vector have wildly differing sizes by design, so
>  normalizing by the largest vector isn't what you want.

This is good to know.  Are there similar statements that can be made
about matrix multiplication in scipy?  If one is multiplying numerous
matrices together, this could be relevant.



More information about the SciPy-User mailing list