hi,<br><br>I encountered a very weird problem tonight. First I created an array and did element-wise multiplication on it:<br><br><div style="margin-left: 40px;">>>> a=zeros((3,3)) + eye(3)<br>>>> a*a<br>
array([[ 1., 0., 0.],<br> [ 0., 1., 0.],<br> [ 0., 0., 1.]])<br></div><br>Then i assigned a value to one of the element:<br><br><div style="margin-left: 40px;">>>> a[1,2]=4<br></div><br>Finally, the '*' operator was interpreted as a matrix multiplication<br>
<br><div style="margin-left: 40px;">>>> a*a<br>array([[ 1., 0., 0.],<br> [ 0., 1., 16.],<br> [ 0., 0., 1.]])<br></div><br> The return types of zeros() and eye() are both arrays. <br><br>
The even weird thing happened later. When I do the same thing in another program (obtaining an adjacency matrix and computing graph powers), my "matrix" was considered as an ''array."<br><br>So, why could an element assignment turn an array into a matrix? And sometimes not? <br>
<br>Cheers, Forrest<br>