[SciPy-user] multiplying scalar with complex matrix segfaults

Andre Radke lists at spicynoodles.net
Thu Jan 19 13:53:01 CST 2006

When I try to multiply a float value with a complex matrix object, I get unexpected results or even a segfault, e.g.:

jannu:~ andre$ /usr/local/bin/python
ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
Python 2.4.2 (#1, Oct  3 2005, 09:39:46) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy import *
>>> 1.0 * matrix(eye(3, dtype=complex))
matrix([[ 1.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j,  0.+0.j],
       [ 0.+0.j,  0.+0.j,  1.+0.j]])
>>> 1.0 * matrix(eye(41, dtype=complex))
Segmentation fault

I'm aware that the matrix class overrides the * operator with matrix multiplication and that's why I want to use it. However, I still expected a scalar multiplied with a matrix to yield a matrix where each entry has been multiplied with that scalar.

In other words, I would expect both examples shown above to return the identity matrix of the appropriate shape. Obviously, that's not the case, at least not on my machine.

Can anybody else reproduce this?

This is using NumPy, SciPy, and ActivePython 2.4.2 on Mac OS X 10.3.9.




P.S. Here's the relevant portion of the crash log. It looks like the segfault occurs in the ATLAS zaxpy function:

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0x031090c0

Thread 0 Crashed:
0   libBLAS.dylib                  	0x9550f6e4 ATL_zaxpy_xp0yp0aXbX + 0x1c
1   _dotblas.so                    	0x0069beb8 dotblas_matrixproduct + 0x8d4 (_dotblas.c:341)
2   org.activestate.ActivePython24 	0x1007c4a0 call_function + 0x3bc (ceval.c:3558)
3   org.activestate.ActivePython24 	0x10079f4c PyEval_EvalFrame + 0x22b8 (ceval.c:2163)
4   org.activestate.ActivePython24 	0x1007b0b4 PyEval_EvalCodeEx + 0x868 (ceval.c:2736)
5   org.activestate.ActivePython24 	0x10025a48 function_call + 0x158 (funcobject.c:548)
6   org.activestate.ActivePython24 	0x1000badc PyObject_Call + 0x30 (abstract.c:1757)
7   org.activestate.ActivePython24 	0x1001526c instancemethod_call + 0x31c (classobject.c:2448)
8   org.activestate.ActivePython24 	0x1000badc PyObject_Call + 0x30 (abstract.c:1757)
9   org.activestate.ActivePython24 	0x10052a80 call_maybe + 0x128 (typeobject.c:963)
10  org.activestate.ActivePython24 	0x1000bd00 binary_op1 + 0x180 (abstract.c:378)
11  org.activestate.ActivePython24 	0x1000a518 PyNumber_Multiply + 0x28 (abstract.c:673)
12  org.activestate.ActivePython24 	0x100784ec PyEval_EvalFrame + 0x858 (ceval.c:1049)
13  org.activestate.ActivePython24 	0x1007b0b4 PyEval_EvalCodeEx + 0x868 (ceval.c:2736)
14  org.activestate.ActivePython24 	0x1007e52c PyEval_EvalCode + 0x30 (ceval.c:484)
15  org.activestate.ActivePython24 	0x100b2ebc run_node + 0x4c (pythonrun.c:1265)
16  org.activestate.ActivePython24 	0x100b238c PyRun_InteractiveOneFlags + 0x200 (pythonrun.c:763)
17  org.activestate.ActivePython24 	0x100b216c PyRun_InteractiveLoopFlags + 0x10c (pythonrun.c:699)
18  org.activestate.ActivePython24 	0x100b3c10 PyRun_AnyFileExFlags + 0xa4 (pythonrun.c:659)
19  org.activestate.ActivePython24 	0x100bf6e0 Py_Main + 0xa2c (main.c:487)
20  python                         	0x000018d0 _start + 0x188 (crt.c:267)
21  dyld                           	0x8fe1a278 _dyld_start + 0x64

Andre Radke + mailto:lists at spicynoodles.net + http://spicynoodles.net/

More information about the SciPy-user mailing list