numpy.dot()


Advertisements

This function returns the dot product of two arrays. For 2-D vectors, it is the equivalent to matrix multiplication. For 1-D arrays, it is the inner product of the vectors. For N-dimensional arrays, it is a sum product over the last axis of a and the second-last axis of b.

import numpy.matlib 
import numpy as np 

a = np.array([[1,2],[3,4]]) 
b = np.array([[11,12],[13,14]]) 
np.dot(a,b)

It will produce the following output −

[[37  40] 
 [85  92]] 

Note that the dot product is calculated as −

[[1*11+2*13, 1*12+2*14],[3*11+4*13, 3*12+4*14]]
numpy_linear_algebra.htm
Advertisements