python matrix algorithms

Solutions on MaxInterview for python matrix algorithms by the best coders in the world

showing results for - "python matrix algorithms"
Imrane
04 Mar 2020
1import numpy 
2
3x = numpy.array([[1, 2], [4, 5]]) 
4y = numpy.array([[7, 8], [9, 10]]) 
5
6# using sqrt() to print the square root of matrix 
7print ("The element wise square root is : ") 
8print (numpy.sqrt(x)) 
9  
10# using sum() to print summation of all elements of matrix 
11print ("The summation of all matrix element is : ") 
12print (numpy.sum(y)) 
13  
14# using sum(axis=0) to print summation of all columns of matrix 
15print ("The column wise summation of all matrix  is : ") 
16print (numpy.sum(y,axis=0)) 
17  
18# using sum(axis=1) to print summation of all columns of matrix 
19print ("The row wise summation of all matrix  is : ") 
20print (numpy.sum(y,axis=1)) 
21  
22# using "T" to transpose the matrix 
23print ("The transpose of given matrix is : ") 
24print (x.T)