Numpy: multiply, matmul, dot for matrices
examples/numpy/multiply_matrixes.py
import numpy as np a = np.array([[1, 2, 3], [4, 5, 6]]) b = np.array([[1, 3, 4], [7, 8, 0]]) print(a) print(b) print() print(a*b) print(b*a) print() print(np.multiply(a, b)) print() print( np.dot(a, b.transpose()) ) print( np.matmul(a, b.transpose()) ) print() print( np.dot(a.transpose(), b) ) print( np.matmul(a.transpose(), b) )
[[1 2 3] [4 5 6]] [[1 3 4] [7 8 0]] [[ 1 6 12] [28 40 0]] [[ 1 6 12] [28 40 0]] [[ 1 6 12] [28 40 0]] [[19 23] [43 68]] [[19 23] [43 68]] [[29 35 4] [37 46 8] [45 57 12]] [[29 35 4] [37 46 8] [45 57 12]]