C++ Program to check Involutory Matrix Last Updated : 19 Dec, 2022 Comments Improve Suggest changes Like Article Like Report Given a matrix and the task is to check matrix is an involutory matrix or not. Involutory Matrix: A matrix is said to be an involutory matrix if matrix multiply by itself returns the identity matrix. The involutory matrix is the matrix that is its own inverse. The matrix A is said to be an involutory matrix if A * A = I. Where I is the identity matrix. Examples: Input : mat[N][N] = {{1, 0, 0}, {0, -1, 0}, {0, 0, -1}} Output : Involutory Matrix Input : mat[N][N] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} Output : Involutory Matrix C++ // Program to implement involutory matrix. #include <bits/stdc++.h> #define N 3 using namespace std; // Function for matrix multiplication. void multiply(int mat[][N], int res[][N]) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { res[i][j] = 0; for (int k = 0; k < N; k++) res[i][j] += mat[i][k] * mat[k][j]; } } } // Function to check involutory matrix. bool InvolutoryMatrix(int mat[N][N]) { int res[N][N]; // multiply function call. multiply(mat, res); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == j && res[i][j] != 1) return false; if (i != j && res[i][j] != 0) return false; } } return true; } // Driver function. int main() { int mat[N][N] = { { 1, 0, 0 }, { 0, -1, 0 }, { 0, 0, -1 } }; // Function call. If function return // true then if part will execute otherwise // else part will execute. if (InvolutoryMatrix(mat)) cout << "Involutory Matrix"; else cout << "Not Involutory Matrix"; return 0; } Output : Involutory Matrix Time complexity: O(N3)Auxiliary space: O(N2) Please refer complete article on Program to check Involutory Matrix for more details! Comment More infoAdvertise with us Next Article C++ Program to check Involutory Matrix kartik Follow Improve Article Tags : Mathematical Matrix C++ Programs C++ DSA +1 More Practice Tags : CPPMathematicalMatrix Similar Reads C++ Program to check idempotent matrix Given N * N matrix and the task is to check matrix is an idempotent matrix or not.Idempotent matrix: A matrix is said to be an idempotent matrix if the matrix multiplied by itself returns the same matrix. The matrix M is said to be an idempotent matrix if and only if M * M = M. In an idempotent matr 2 min read C++ Program to check if matrix is lower triangular Given a square matrix and the task is to check the matrix is in lower triangular form or not. A square matrix is called lower triangular if all the entries above the main diagonal are zero. Examples: Input : mat[4][4] = {{1, 0, 0, 0}, {1, 4, 0, 0}, {4, 6, 2, 0}, {0, 4, 7, 6}}; Output : Matrix is in 2 min read C++ Program to check if a matrix is symmetric A square matrix is said to be symmetric matrix if the transpose of the matrix is same as the given matrix. Symmetric matrix can be obtain by changing row to column and column to row. Examples: Input : 1 2 3 2 1 4 3 4 3 Output : Yes Input : 3 5 8 3 4 7 8 5 3 Output : No A Simple solution is to do fo 3 min read C++ Program for Identity Matrix Introduction to Identity Matrix : The dictionary definition of an Identity Matrix is a square matrix in which all the elements of the principal or main diagonal are 1's and all other elements are zeros. In the below image, every matrix is an Identity Matrix. In linear algebra, this is sometimes call 3 min read C++ Program To Check if Two Matrices are Identical The below program checks if two square matrices of size 4*4 are identical or not. For any two matrices to be equal, the number of rows and columns in both the matrix should be equal and the corresponding elements should also be equal. Recommended: Please solve it on "PRACTICE" first, before moving 2 min read Like