Javascript Program to check Involutory Matrix Last Updated : 12 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a matrix, the task is to check matrix is an involutory matrix or not. Involutory Matrix: A matrix is said to be an involutory matrix if the matrix multiplied by itself returns the identity matrix. The involutory matrix is the matrix that is its 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 MatrixInput : mat[N][N] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} Output : Involutory Matrix JavaScript // Javascript to implement involutory matrix. let N = 3; // Function for matrix multiplication. function multiply(mat, res) { for (let i = 0; i < N; i++) { for (let j = 0; j < N; j++) { res[i][j] = 0; for (let k = 0; k < N; k++) res[i][j] += mat[i][k] * mat[k][j]; } } } // Function to check involutory matrix. function InvolutoryMatrix(mat) { let res = Array(N).fill(0).map( x => Array(N).fill(0)); // Multiply function call. multiply(mat, res); for (let i = 0; i < N; i++) { for (let 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 code let mat = [[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)) console.log("Involutory Matrix"); else console.log("Not Involutory Matrix"); // This code is contributed by 29AjayKumar OutputInvolutory Matrix Complexity Analysis:Time complexity: O(N3) as three nested loops are executing. Here N is size of rows and columns.Auxiliary space: O(N2) as res 2d matrix has been created.Please refer complete article on Program to check Involutory Matrix for more details! Comment More infoAdvertise with us Next Article Javascript Program to check Involutory Matrix K kartik Follow Improve Article Tags : JavaScript Similar Reads Javascript Program to check idempotent matrix Given an 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 m 2 min read Javascript 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 : NoA Simple solution is to do follo 2 min read Javascript Program for Diagonally Dominant Matrix In mathematics, a square matrix is said to be diagonally dominant if for every row of the matrix, the magnitude of the diagonal entry in a row is larger than or equal to the sum of the magnitudes of all the other (non-diagonal) entries in that row. More precisely, the matrix A is diagonally dominant 2 min read JavaScript Program to Check if a Given Square Matrix is an Identity Matrix Given a matrix, our task is to check if a given square matrix is an Identity Matrix. An identity matrix (unit matrix) is a square matrix in which the principal diagonal elements are all one and other elements in the matrix are zero. Example:Input:[ [ 1, 0, 0] , [0, 1, 0] , [0, 0, 1]] Output: True Be 3 min read Javascript Program to Print a given matrix in reverse spiral form Given a 2D array, print it in reverse spiral form. We have already discussed Print a given matrix in spiral form. This article discusses how to do the reverse printing. See the following examples. Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16Output: 10 11 7 6 5 9 13 14 15 16 12 8 4 3 2 1Input: 1 2 3 3 min read Like