[Numpy-discussion] untenable matrix behavior in SVN

Anne Archibald peridot.faceted@gmail....
Tue Apr 29 16:16:15 CDT 2008


On 29/04/2008, Gael Varoquaux <gael.varoquaux@normalesup.org> wrote:
> On Tue, Apr 29, 2008 at 11:03:58PM +0200, Anne Archibald wrote:
>  > I am puzzled by this. What is the rationale for x[i,:] not being a 1-d
>  > object?
>
> It breaks A*B[i, :] where A and B are matrices.

Really? How?

In [26]: A = np.matrix([[1,0],[0,1],[1,1]])

In [28]: A*np.ones(2)
Out[28]: matrix([[ 1.,  1.,  2.]])

In [29]: np.ones(3)*A
Out[29]: matrix([[ 2.,  2.]])


I guess you don't get dot products with *:

In [30]: np.ones(3).T*np.ones(3)
Out[30]: array([ 1.,  1.,  1.])

Since the whole point of matrices it to avoid having to type "dot" I
guess this should be convincing.


Anne


More information about the Numpy-discussion mailing list