Operation on the matrix:
1. add (): — This function is used to elementwise addition of a matrix .
2. subtract (): — This function is used to subtract matrix elements .
3. Divide (): — This function is used to elementwise division of a matrix .

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 division of matrix is: [[0.14285714 0.25] [0.44444444 0.5]]
4. multiply (): — This function is used to multiply a matrix by a element .
5. dot (): — This function is used to calculate matrix multiplication, not elementwise multiplication .
# Python code to demonstrate matrix operations
# multiply () and dot ()
# numpy imports for matrix operations
import
numpy
# matrix initialization
x
=
numpy.array ([[
1
,
2
] , [
4
,
5
]])
y
=
numpy.array ([[
7
,
8
], [
9
,
10
]])
# using multiply () to multiply matrices by elements
print
( "The element wise multiplication of matrix is:"
)
print
(numpy.multiply (x, y))
# using dot () to multiply matrices
print
(
"T he product of matrices is: "
)
print
(numpy.dot (x, y))
Output:
The element wise multiplication of matrix is: [[7 16] [36 50]] The product of matrices is: [[25 28] [73 82]]
6. sqrt (): — This function is used to calculate the square root of each element of the matrix.
7. sum (x, axis): — This function is used to add all elements to the matrix . The optional axis argument calculates the column sum if the axis is 0, and the row sum if the axis is 1 .
8. "T": — This argument is used to transpose the specified matrix.

Output:
The element wise square root is: [[1. 1.41421356] [2. 2.23606798]] The summation of all matrix element is: 34 The column wise summation of all matrix is: [16 18] The row wise summation of all matrix is: [15 19] The transpose of a given matrix is: [[1 4] [2 5]]
This article is courtesy of Manjit Singh 100
It’s in all of us. Data science is what makes us humans what we are today. No, not the computerdriven da...
10/07/2020
Google BigQuery: The Definitive Guide PDF download. Data Warehousing, Analytics, and Machine Learning at Scale, 1st Edition, 2019. Work with petabytescale datasets while building a collaborative a...
31/08/2021
Systems programming provides the basis for global calculation. Developing performancesensitive code requires a programming language that allows programmers to control the use of memory, processor tim...
23/09/2021
Topics on Big Data are growing rapidly. From the first 3 V’s that originally characterized Big Data, the industry now has identified 42 V’s associated with Big Data. The list of how we characteriz...
10/07/2020