The Wayback Machine - https://web.archive.org/web/20240604220500/https://www.geeksforgeeks.org/python-numpy-matrix-dot/
Open In App

Python | Numpy matrix.dot()

Last Updated : 12 Apr, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

With the help of Numpy matrix.dot() method, we are able to find a product of two given matrix and gives output as new dimensional matrix.

Syntax : matrix.dot()

Return : Return product of two matrix

Example #1 :
In this example we can see that with the help of matrix.dot() method we are able to find the product of two given matrix.




# import the important module in python
import numpy as np
         
# make matrix with numpy
gfg1 = np.matrix('[6, 2, 3]')
gfg2 = np.matrix('[4; 5; 9]')
         
# applying matrix.dot() method
geeks = gfg1.dot(gfg2)
   
print(geeks)


Output:

[[61]]

Example #2 :




# import the important module in python
import numpy as np
         
# make a matrix with numpy
gfg1 = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
gfg2 = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
         
# applying matrix.dot() method
geeks = gfg1.dot(gfg2)
   
print(geeks)


Output:

[[ 30  36  42]
 [ 66  81  96]
 [102 126 150]]

Similar Reads

Numpy recarray.dot() function | Python
In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record arrays allow the fields to be accessed as members of th
3 min read
Numpy MaskedArray.dot() function | Python
numpy.MaskedArray.dot() function is used to calculate the dot product of two mask arrays. Syntax : numpy.ma.dot(arr1, arr2, strict=False) Parameters: arr1, arr2:[ ndarray] Inputs arrays. strict : [bool, optional] Whether masked data are propagated (True) or set to 0 (False) for the computation. Default is False. Return : [ ndarray] The dot product
3 min read
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 : # Python program explaining # numpy.ndarray.dot() function # importing numpy as geek import n
1 min read
Difference between NumPy.dot() and '*' operation in Python
In Python if we have two numpy arrays which are often referred as a vector. The '*' operator and numpy.dot() work differently on them. It's important to know especially when you are dealing with data science or competitive programming problem. Working of '*' operator '*' operation caries out element-wise multiplication on array elements. The elemen
2 min read
Python Program to Get dot product of multidimensional Vectors using NumPy
Given two multidimensional Vectors, the task is to write a Python program to get the dot product of two multidimensional Vectors using NumPy. Example: Lets take 2 vectors a = [2,5,3] and b = [6,3,1] Dot Product(ab) = (a[0] * b[0])+ (a[1] * b[1]) + (a[2] * b[2]) = (2*6)+ (5*3) + (3*1) = 30 Dot Product is the sum of the product of elements at each po
4 min read
numpy.dot() in Python
numpy.dot(vector_a, vector_b, out = None) returns the dot product of vectors a and b. It can handle 2D arrays but considers 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]) Parameters vector_a : [array_like]
2 min read
Python | Numpy numpy.matrix.any()
With the help of Numpy numpy.matrix.any() method, we are able to compare each and every element of one matrix with another or we can provide the axis on the we want to apply comparison if any of the element matches it return true. Syntax : numpy.matrix.any() Return : Return true if any match found else false Example #1 : In this example we can see
1 min read
Python | Numpy numpy.matrix.all()
With the help of Numpy numpy.matrix.all() method, we are able to compare each and every element of one matrix with another or we can provide the axis on the we want to apply comparison. Syntax : numpy.matrix.all() Return : Return true if found match else false Example #1 : In this example we can see that with the help of matrix.all() method, we are
1 min read
Python | Numpy numpy.matrix.A()
With the help of Numpy numpy.matrix.A() method, we can get the same matrix as self. It means through this method we can get the identical matrix. Syntax : numpy.matrix.A() Return : Return self matrix Example #1 : In this example we can see that with the help of matrix.A() method, we are able to get the self matrix. # import the important module in
1 min read
Python | Numpy numpy.matrix.T()
With the help of Numpy numpy.matrix.T() method, we can make a Transpose of any matrix either having dimension one or more than more. Syntax : numpy.matrix.T() Return : Return transpose of every matrix Example #1 : In this example we can see that with the help of matrix.T() method, we are able to transform any type of matrix. # import the important
1 min read
Practice Tags :