[Matrix-SIG] possible bug in NumPy

Paul F. Dubois Paul F. Dubois" <dubois1@llnl.gov
Tue, 5 May 1998 08:11:24 -0700


Numerical calculations are almost never precise, so testing for equality is
not often the right thing to do.

To continue your calculation:
>>> d=abs(a-b)
>>> d
array([[ 0.1,  0.1],
       [ 0.1,  0.1]])

>>> d-c
array([[ 8.32667268e-017,  8.32667268e-017],
       [ 8.32667268e-017,  8.32667268e-017]])
>>>

-----Original Message-----
From: Oliver Gathmann <gathmann@scar.utoronto.ca>
To: matrix-sig@python.org <matrix-sig@python.org>
Date: Tuesday, May 05, 1998 7:26 AM
Subject: [Matrix-SIG] possible bug in NumPy


>Hi all,
>
>I think I found what looks like a bug in NumPy (I am not up to date with
>the very latest release, but I don't remember this coming up here before):
>
>Python 1.5 (#3, Feb 12 1998, 12:14:31)  [GCC 2.7.2.3] on linux2
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> from Numeric import *
>>>> a = array([[1,1],[2,2]])
>>>> b = array([[1.1,1.1],[2.1,2.1]])
>>>> c = array([[0.1,0.1],[0.1,0.1]])
>>>> abs(a-b)
>array([[0.1,0.1],
>       [0.1,0.1]])
>>>> less_equal(abs(a-b),c)
>array([[0, 0],
>       [0, 0]])
>>>> less_equal(c,abs(a-b))
>array([[1, 1],
>       [1, 1]])
>
>Shouldn't that be 'all true' in both cases since abs(a-b) and c are the
>same thing?
>
>Oliver
>
>Oliver Gathmann (gathmann@scar.utoronto.ca)
>Surface and Groundwater Ecology Research Group
>University of Toronto
>phone: (416) - 287 7420 ; fax: (416) - 287 7423
>
>
>
>------------------------------------------------------
>Matrix-SIG maillist  -  Matrix-SIG@python.org
>http://www.python.org/mailman/listinfo/matrix-sig
>