Overview:
- The dot() function returns the dot product of two NumPy arrays.
Example 1 - Dot product of two 1-dimensional arrays:
- As both the input arrays in the example are one-dimensional the return value is a scalar.
# Example Python program that finds the dot product of # Create array1 # Create array2 # Find the dot product of two arrays |
Output:
32 |
Example 2 - Dot product of two 2-dimensional arrays:
# Example Python program that multiplies two 2-dimensional # Create matrix1 # Create matrix2 dotProduct = numpy.dot(array1, array2) |
Output:
[[0 1 2] [3 4 5] [6 7 8]] [[0 1 2] [3 4 5] [6 7 8]] [[ 15 18 21] [ 42 54 66] [ 69 90 111]] |