Apr 24, 2013

Numpy Matrix Multiplication


In : a
Out: 
array([[0, 1, 2],
       [3, 4, 5]])

In : b
Out: 
array([[0, 1, 2],
       [3, 4, 5]])

# Matrix Multiplication
In : np.dot(a,b.T)
Out: 
array([[ 5, 14],
       [14, 50]])

In : np.dot(a,b)
ValueError: objects are not aligned

# Elementwise multiplication
In : a*b
Out: 
array([[ 0,  1,  4],
       [ 9, 16, 25]])