[NumPy-Tickets] [NumPy] #1980: Matrix A from zeros, after changing values, yields strange A*A.T behavior

NumPy Trac numpy-tickets@scipy....
Wed Nov 16 18:15:47 CST 2011


#1980: Matrix A from zeros, after changing values, yields strange A*A.T behavior
----------------------+-----------------------------------------------------
 Reporter:  ehassler  |       Owner:  somebody   
     Type:  defect    |      Status:  new        
 Priority:  normal    |   Milestone:  Unscheduled
Component:  Other     |     Version:  1.6.0      
 Keywords:            |  
----------------------+-----------------------------------------------------

Comment(by warren.weckesser):

 This has nothing to do with zeros().  In your sample code, P0 is an
 ndarray, but P1 is a matrix object.  Multiplication of ndarrays is
 element-wise, not algebraic.  To perform the algebraic product of two
 ndarrays, use the dot() method (or the numpy.dot() function).
 Multiplication of matrix objects, however, is defined to be the usual
 algebraic matrix product.  So you want this comparison in your script
 (which will print True):
 {{{
 print numpy.all(P0.dot(P0.T) == P1*P1.T)
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1980#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list