World Languages, asked by vasamsettimangadevi9, 1 month ago

Single File Programming Question
Rahul's teacher gave him an assignment as he scored very low marks
in his internal exam. His assignment was to find if a matrix is involutor
or not. Given a matrix A, write a program to help Rahul find if the given
matrix A is an involutory matrix or not.
Involutory Matrix: The matrix A is said to be an involutory matrix if A*
= 1, where I is the identity matrix.
Example 1
Input
3
1 0 0
010
001​

Answers

Answered by biplabsarkar00888
1

Answer:

i forgot the sorry I didn't know the answer

Answered by remonticsid1817
0

Answer:

def multiply(matrix, res):

for i in range(R):

for j in range(R):

res[i][j] = 0;

for k in range(R):

res[i][j] += matrix[i][k] * matrix[k][j];

return res;

def InvolutoryMatrix(matrix):

res=[[0 for i in range(R)]

for j in range(R)];

res = multiply(matrix, res);

for i in range(R):

for j in range(R):

if (i == j and res[i][j] != 1):

return False;

if (i != j and res[i][j] != 0):

return False;

return True;

R = int(input())

matrix = []

for i in range(R):

a =[]

for j in range(R):

a.append(int(input()))

matrix.append(a)

if (InvolutoryMatrix(matrix)):

print("True")

for i in range(R):

for j in range(R):

print(matrix[i][j], end = " ")

print()

else:

print("False")

for i in range(R):

for j in range(R):

print(matrix[i][j], end = " ")

print()

Similar questions