numpy.dot(vector_a, vector_b, out = None) returns the dot product of vectors a and b. It can handle 2D arrays but considering them as matrix and will perform matrix multiplication. For N dimensions it is a sum product over the last axis of a and the second-to-last of b :
dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
- vector_a : [array_like] if a is complex its complex conjugate is used for the calculation of the dot product.
- vector_b : [array_like] if b is complex its complex conjugate is used for the calculation of the dot product.
- out : [array, optional] output argument must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a,b).
Dot Product of vectors a and b. if vector_a and vector_b are 1D, then scalar is returned
Code 1 –
Dot Product of scalar values : 20 Dot Product : (-7+22j)
How Code1 works ?
vector_a = 2 + 3j
vector_b = 4 + 5j
now dot product
= 2(4 + 5j) + 3j(4 – 5j)
= 8 + 10j + 12j – 15
= -7 + 22j
Code 2 –
Dot Product : [[22 12] [40 32]] Dot Product : [[22 32] [15 32]]
This article is contributed by Mohit Gupta_OMG 😀. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Important differences between Python 2.x and Python 3.x with examples
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- MySQL-Connector-Python module in Python
- Python - Read blob object in python using wand library
- Python | PRAW - Python Reddit API Wrapper
- twitter-text-python (ttp) module - Python
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python program to check if the list contains three consecutive common numbers in Python
- Creating and updating PowerPoint Presentations in Python using python - pptx
- How to write an empty function in Python - pass statement?
- Operator Functions in Python | Set 2