[Numpy-tickets] [NumPy] #473: Matrix multiplication returns wrong result
NumPy
numpy-tickets@scipy....
Fri Mar 23 17:32:45 CDT 2007
#473: Matrix multiplication returns wrong result
-----------------------------------+----------------------------------------
Reporter: charris | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone:
Component: numpy.core | Version: 1.0.1
Severity: normal | Resolution:
Keywords: matrix multiplication |
-----------------------------------+----------------------------------------
Comment (by charris):
The calling sequence goes as
__mul__
dot
array_matrixproduct
PyArray_MatrixProduct
new_array_for_sum
PyArray_New
It looks like PyArray_New actually creates the output array and it simply
doesn't have the information needed to do anything other than the default
creation which is 1-D arrays -> row vector. The best place to add the
needed information is probably right up at the beginning in __mul__, where
a check can be made for the subtype of the other and the vector shape
adjusted as needed. It is a bit tricky, because Ax doesn't mean that x is
always a column vector, it might remain a row vector if A is a scalar
matrix like [[1]]. One could, I suppose, simply throw an error for mixed
multiplication, but that might break some code and seems overly
restrictive.
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/473#comment:1>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list