Matrices Implementations

Last updated: 2nd Dec, 2020
Rotating a matrix

Module: matrices()
Method : rotateImage(matrix,n,hint=False)
Uses : To rotate an input square matrix, this function retruns nothing but changes the input square matrix itself.
Parameters : matrix - a two dimensional array as python list, n is the number of rows in the matrix, hint is passed False by default, by declaring hint=True a detailed description of the rotation algorithm can be found.

Python Code Example
from edualgo import algorithms as al
img_arr = [[1,2,3],[4,5,6],[7,8,9]]
ping2 = al.matrices()
ping2.rotateImage(img_arr,3)
Output:
img_arr = [[7, 4, 1], [8, 5, 2], [9, 6, 3]]

    
For getting the hint just pass hint=True in the function like - rotateImage(img_arr,n,True).
Set Zeros

Module: matrices()
Method : setZeros(matrix,row,column)
Uses : This function sets the entire row and column of the matrix as zero if it encounters zero at any position of the matrix. This function returns nothing, the changes take place in the input matrix itself.
Parameters : matrix - a two dimensional array as python list, row - the number of rows in the matrix,columns - the number of columns in the matrix.

Python Code Example
from edualgo import algorithms as al
img_arr = [[1,0,3],[4,5,6],[7,8,9]]
ping2 = al.matrices()
ping2.setZeros(img_arr,3,3)
Output:
img_arr = [[0, 0, 0], [4, 0, 6], [7, 0, 9]]


    

Are you an ambitious Python Developer ?

Instance Theme

Do you want to contribute to our project ? We welcome every python lover to come forwards and have some fun with our source code. Steps to contibute:

  • Send an email to the developer here regarding your willingness to contribute to the project.
  • Have a read of our "How To Contribute" documentation here.
Keep coding, keep loving python