add array
add array
# initializing matrices
print (numpy.add(x,y))
print (numpy.subtract(x,y))
print (numpy.multiply(x,y))
# using divide() to divide matrices
print (numpy.divide(x,y))
Output:
The element wise addition of matrix is :
[[8 10]
[13 15]]
The element wise subtraction of matrix is :
[[-6 -6]
[-5 -5]]
The element wise multiplication of matrix is:
[[7 16]
[36 50]]
The element wise division of matrix is:
[[0.14285714 0.25 ]
[0.44444444 0.5 ]]
Dot and cross product with Matrix
Here, we will find the inner, outer, and cross products of matrices and vectors
using NumPy in Python.
Python3
dotproduct = np.dot(X, Y)
dotproduct = np.cross(X, Y)