Charles R Harris wrote: > > > On 3/24/07, *Travis Oliphant* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Alan G Isaac wrote: > > On Sat, 24 Mar 2007, Charles R Harris apparently wrote: > > > >> Yes, that is what I am thinking. Given that there are only the two > >> possibilities, row or column, choose the only one that is > compatible with > >> the multiplying matrix. The result will not always be a column > vector, for > >> instance, mat([[1]])*ones(3) will be a 1x3 row vector. > >> > > > > > > > > Ack! The simple rule `post multiply means its a column vector` > > would be horrible enough: A*ones(n)*B becomes utterly obscure. > > Now even that simple rule is to be violated?? > > > > Down this path lies madness. > > Please, just raise an exception. > > > > My opinion is that a 1-d array in matrix-multiplication should > always be > interpreted as a row vector. Is this not what is currently done? If > not, then it is a bug in my mind. > > > Fair enough. But in that case mat(eye(2))*ones(2) should raise an > error instead of returning a row vector. > > In [1]: mat(eye(2))*ones(2) > Out[1]: matrix([[ 1., 1.]]) > > The problem is that the return object is created as a row matrix and > then filled as if the rhs was a column vector in > PyArray_MatrixProduct. So this should be made a bug? > Yes, as you describe, dot allows 2x2 times a 1-d array (and interprets the 1-d array as a column vector). This has always been the behavior of dot and won't change.
But, that doesn't mean we have to allow this behavior for matrices. In other words we should probably check against it for matrix-multiplication. The dot operator allows mixing n-d arrays, but I'm persuaded that the matrix multiplication should only work for 2-d arrays and if it is given a 1-d array, it seems that it should have a specific interpretation of that 1-d array as a 2-d array. -Travis > Chuck > > > ------------------------------------------------------------------------ > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion