[Numpy-discussion] "Segmentation fault (core dumped)" as result of matrix multiplication
Marius Nijhuis
mariusnijhuis@gmail....
Tue May 6 07:15:29 CDT 2008
Hello,
I encountered the error "Segmentation fault (core dumped)" during a rather
standard multiplication, without excessive memory us. This looks likes a
bug to me?
I am using Python 2.5, Numpy 1.0.4 under Ubuntu 7.10.
Here is what I am doing: i have two arrays, points1 and points2.
points1.shape=(n,k)
points2.shape=(m,k)
The problem only happens if n or m (or both) are 1. The arrays are then
still 2-dimensional. k is usually in the order of 60.
The code:
p1Mat=asmatrix(points1)
p2Mat=asmatrix(points2).T
ab=p1Mat*p2Mat
At the third line, python crashes back to terminal with the text
"Segmentation fault (core dumped)"
Tracing further the error happens at line 106 of numpy/core/defmatrix.py
If I understand correctly, the __mul__ method of p1Mat calls
N.dot(self, asmatrix(other))
and the problem occurs in asmatrix(other) , i.e. before actual
multiplication is done.
To be more precise, at some point the code calls __array_finalize__ twice,
nested, and the error happens on the second return from it. I am not 100%
sure what is done here, but it looks as if the asmatrix command I gave
myself is somehow conflicting with the asmatrix command given by __mul__
I have replaced my code with:
p1Mat=sp.matrix(points1)
p2Mat=sp.matrix(points2).T
ab=p1Mat*p2Mat
and this works fine.
I hope this information is useful to someone?
Marius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080506/4ce7118d/attachment.html
More information about the Numpy-discussion
mailing list