[Numpy-discussion] an array become a matrix after an element assignment
Forrest Sheng Bao
forrest.bao at gmail.com
Sat Apr 16 23:51:52 EDT 2011
Oh yeah, my bad. Forget about it. I guess I was too tired.
Cheers, Forrest
On Sat, Apr 16, 2011 at 10:47 PM, Nathaniel Smith <njs at pobox.com> wrote:
> On Sat, Apr 16, 2011 at 8:39 PM, Forrest Sheng Bao
> <forrest.bao at gmail.com> wrote:
> >>>> a=zeros((3,3)) + eye(3)
> >>>> a*a
> > array([[ 1., 0., 0.],
> > [ 0., 1., 0.],
> > [ 0., 0., 1.]])
> >
> > Then i assigned a value to one of the element:
> >
> >>>> a[1,2]=4
> >
> > Finally, the '*' operator was interpreted as a matrix multiplication
> >
> >>>> a*a
> > array([[ 1., 0., 0.],
> > [ 0., 1., 16.],
> > [ 0., 0., 1.]])
>
> That looks like element-wise multiplication to me? (Matrix
> multiplication would have given you an 8 where you have a 16.)
>
> -- Nathaniel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110416/0115e243/attachment.html>
More information about the NumPy-Discussion
mailing list