# [MATRIX-SIG] Weird bug

**Jim Hugunin
**
hugunin@CNRI.Reston.Va.US

*Sat, 30 Aug 1997 12:59:09 -0400*

I understand exactly what's going on here, and I'd argue that in fact it
is NOT a bug. The problem is related to the choice early on for things
like transpose(a) to point to the same memory as the original 'a' does.
Naive users are strongly discouraged from using the 3-argument numeric
functions and it is exactly this sort of behavior that is behind these
warnings. If you realize that 'a' and transpose(a) both point to the
same region of memory this "bug" makes perfect sense. In fact, there's
no alternative way of implementing things that would make this "bug" go
away without making 3-argument numeric functions use a temporary array
for storing their result, which would completely eliminate their
usefulness.
-Jim
Konrad Hinsen wrote:
>*
*>* I have hit the following bug which looks really dangerous to me - wrong
*>* results in a perfectly ordinary situation:
*>*
*>* >>> from Numeric import *
*>* >>> a = array([[1,2],[3,4]])
*>* >>> a + transpose(a)
*>* array([[2, 5],
*>* [5, 8]])
*>* >>> add(a, transpose(a))
*>* array([[2, 5],
*>* [5, 8]])
*>* >>> add(a, transpose(a), a)
*>* array([[2, 5],
*>* [8, 8]])
*>* >>> a
*>* array([[2, 5],
*>* [8, 8]])
*>*
*>* I won't have any time soon to check what's going on, but watch out
*>* for this if you use the three-argument arithmetic functions.
*
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________