You are given an N*N matrix A. You can assume that the input matrix will always be a valid square matrix
(number of rows is same as number of columns) you do not need to check for erroneous inputs. You
cannot use any module or library (such as numpy) while solving the questions. Open matrixOperations.py
and perform the following tasks:
Part A: (12 pts)
Implement a function matrix_transpose(A) which takes the matrix A as an input, computes its transpose
(switching the row and column indices the elements, $A_{ij} \leftarrow A_{ji}$), and returns this computed transpose.
Example: A = [[1, 4, 2],
[2, 1, 7],
[1, 1, 1]] should return
[[1, 2, 1],
[4, 1, 1],
[2, 7, 1]]
Part B: (12 pts)
A symmetric matrix is a square matrix that is equal to its transpose. Implement a function
symmetric_matrix(A) which takes the matrix A as input and checks whether the matrix A is symmetric or
not. If it is symmetric, your function should return 1 (integer), if not your function should return -1 (integer).
You can directly call the matrix_transpose(A) function you wrote in Part A to compute the transpose.
Example: A = [[1, 4, 2],
[2, 1, 7],
[1, 1, 1]] should return -1
A = [[1, 2, 3],
[2, 2, 8],
[3, 8, 6]] should return 1
Part C: (12 pts)
A diagonal matrix is a matrix such that all elements other than the main diagonal are 0. Implement a
function diagonal_matrix(A) which takes the matrix A as input and updates its elements such that all
elements are replaced with zeros except the elements in the first diagonal. Return value should be the new
matrix you computed.
Example: A = [[1, 4, 2],
[2, 1, 7],
[1, 1, 1]] should return [[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
A = [[1, 2, 3],
[2, 2, 8],
[3, 8, 6]] should return [[1, 0, 0],
[0, 2, 0],
[0, 0, 6]]