Changes

Jump to navigation Jump to search

Numpy linalg

500 bytes added, 11:52, 19 June 2014
== Einsum ==
http://chintaksheth.wordpress.com/2013/07/31/numpy-the-tricks-of-the-trade-part-ii/
 
http://stackoverflow.com/questions/14758283/is-there-a-numpy-scipy-dot-product-calculating-only-the-diagonal-entries-of-the
 
<source lang="python">
a = np.arange(4).reshape(2,2)
print a
print "np.einsum('ii', a), row i multiplied downwards"
print np.einsum('ii', a)
 
print "np.einsum('ij', a), same matrix ?"
print np.einsum('ij', a)
 
print "np.einsum('ji', a), transpose"
print np.einsum('ji', a)
 
print "np.einsum('ji', a), dot product"
print np.einsum('ij,jk', a, a)
print np.dot(a, a)
</source>

Navigation menu