numpy.dot() in Python
Python numpy.dot() function returns dot product of two vactors. Two Dimensional actors can be handled as matrix multiplication and the dot product will be returned.
Basic Syntax
Following is the basic syntax for numpy.dot() function in Python:
numpy.dot(vector_a,vector_b)
And the parameters are:
Parameter | Description |
---|---|
vector_a | First vector for dot product. |
vector_b | Second vector for dot product |
Return Value
numpy.dot() function returns dot product of given two vectors.
Example
Following are the examples for numpy.dot() function
Example 1
# Python program for demonstration of numpy.dot() function import numpy as np # 1D vector # first vector a = 3 + 4j # second vector b = 9 + 10j product = np.dot(a, b) print("Dot Product : ", product) # 2D vector # first vector first = np.array([[5,6],[9,10]]) # second vector second = np.array([[12,13],[1,2]]) print("Dot product : ",np.dot(first,second))
The output for the above program is as given below:
Dot Product : (-13+66j)
Dot product : [[ 66, 77],[118, 137]]
Dot product : [[ 66, 77],[118, 137]]
Example 2
# Python program for demonstration of numpy.dot() function import numpy as np result = np.dot(3, 7) print("Dot product : ", result) result = np.dot(9, 8) print("Dot product : ", result)
The output for the above program is as given below:
Dot product : 21
Dot product : 72
Dot product : 72
LATEST POSTS
-
numpy.dtype() in Python
-
numpy.arange() in Python
-
PHP explode() function
-
numpy.loadtxt() in Python
-
numpy.ones() in Python
-
Queue C++
-
C++ do-while loop with Example
-
Java Convert Integer to String
-
numpy.median() in Python
-
numpy.argmin() in Python
-
Read and Write text to files in Python
-
How to Print Without Newline in Python