Numpy ndarray.dot() function | Python

numpy.ndarray.dot() function return the dot product of two arrays.

Syntax : numpy.ndarray.dot(arr, out=None)

Parameters :
arr : [array_like] Input array.
out : [ndarray, optional] Output argument.

Return : [ndarray] The dot product of two arrays.

Code #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program explaining
# numpy.ndarray.dot() function
  
# importing numpy as geek 
import numpy as geek
  
arr1 = geek.eye(3)
arr = geek.ones((3, 3)) * 3
  
gfg = arr1.dot( arr )
  
print( gfg)

chevron_right


Output :

[[ 3.  3.  3.]
 [ 3.  3.  3.]
 [ 3.  3.  3.]]

 
Code #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program explaining
# numpy.ndarray.dot() function
  
# importing numpy as geek 
import numpy as geek
  
arr1 = geek.eye(3)
arr = geek.ones((3, 3)) * 3
  
gfg = arr1.dot(arr).dot(arr)
  
print( gfg)

chevron_right


Output :

[[ 27.  27.  27.]
 [ 27.  27.  27.]
 [ 27.  27.  27.]]
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.