[Numpy-discussion] try to solve issue #2649 and revisit #473

Sebastian Berg sebastian@sipsolutions....
Wed Apr 3 17:12:48 CDT 2013


On Wed, 2013-04-03 at 16:03 -0400, Alan G Isaac wrote:
> On 4/3/2013 3:18 PM, huangkandiy@gmail.com wrote:
> > A 5*5 matrix multiplies another matrix, we expect answer to be error or a 5*? matrix, not a 1*5 matrix.
> 
> 
> That is what happens.
> But you are post"multiplying" a matrix by a one-dimensional list.
> What should happen then?  That is the question.
> 
> One could argue that this should just raise an error,
> or that the result should be 1d.
> In my view, the result should be a 1d array,
> the same as I.A.dot(x).
> 

Would it be reasonable if this was a Nx1 matrix? I am not sure how you
would implement it exactly into dot. Maybe by transposing the result if
the second argument was a vector and the result is not a base class? And
then __mul__ can use np.asarray instead of np.asmatrix. Or just fix
__mul__ itself to transpose the result and don't care about np.dot?

- Sebastian

> But the maintainers wanted operations with matrices to
> return matrices whenever possible.  So instead of
> returning x it returns np.matrix(x).
> 
> My related grievance is that I[0] is a matrix,
> not an array.  There was a long discussion of
> this a couple years ago.
> 
> Anyway, the bottom line is: don't mix matrices and
> other objects.  The matrix object is really built
> only to interact with other matrix objects.
> 
> Alan
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 




More information about the NumPy-Discussion mailing list