Python | Numpy numpy.matrix.all ()

NumPy | Python Methods and Functions

With the Numpy numpy.matrix.all () method, we can compare each element of one matrix to another, or we can provide the axis to which we want to apply the comparison .

Syntax: numpy.matrix.all()

Return: Return true if found match else false

Example # 1:
In this example, we see that using the method matrix.all () we can compare any two matrices that have different dimensions.

# import an important module into python

import numpy as np

 
# make a matrix with NumPy

gfg1 = np.matrix ( `[1, 2, 3, 4]` )

gfg2 = np.matrix ( `[1, 2, 3, 4]` )

  
# using the matrix.all () method

geeks = (gfg1 = = gfg2). all ()

 

print (geeks)

Exit :

 True 

Example # 2:

# import an important module into 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] ` )

  
# using the matrix.all () method

geeks = (gfg1 = = gfg2). all ()

 

print (geeks)

Exit:

 False 




Get Solution for free from DataCamp guru