<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 程序檢查對合矩陣 > 原文: [https://www.geeksforgeeks.org/program-check-involutory-matrix/](https://www.geeksforgeeks.org/program-check-involutory-matrix/) 給定一個矩陣,任務是檢查矩陣是否為非強制矩陣。 [**非對映矩陣**](https://en.wikipedia.org/wiki/Involutory_matrix):如果矩陣本身相乘返回恒等矩陣,則稱該矩陣為非對映矩陣。 對合矩陣是其自身的逆矩陣。 如果 **A * A = I** ,則矩陣 **A** 被稱為??對合矩陣。 我是身份矩陣。 ![Involutory-Matrix](https://img.kancloud.cn/79/ad/79ad1f5ccfc0393aba22b134f3a8589b_588x163.png) **示例**: ``` 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++ ```cpp // 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; } ``` ## Java ```java // Java? Program to implement? // involutory matrix. import java.io.*; class GFG { ????static int N = 3; ????// Function for matrix multiplication. ????static void multiply(int mat[][], int res[][]) ????{ ????????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. ????static boolean InvolutoryMatrix(int mat[][]) ????{ ????????int res[][] = new int[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. ????public static void main (String[] args)? ????{ ????????int 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)) ????????????System.out.println ( "Involutory Matrix"); ????????else ????????????System.out.println ( "Not Involutory Matrix"); ????} } // This code is contributed by vt_m ``` ## Python3 ```py # Program to implement involutory matrix. N = 3; # Function for matrix multiplication. def multiply(mat, res): ????for i in range(N):? ????????for j in range(N): ????????????res[i][j] = 0; ????????????for k in range(N): ????????????????res[i][j] += mat[i][k] * mat[k][j]; ????return res; # Function to check involutory matrix. def InvolutoryMatrix(mat): ????res=[[0 for i in range(N)]? ????????????for j in range(N)]; ????# multiply function call. ????res = multiply(mat, res); ????for i in range(N):? ????????for j in range(N): ????????????if (i == j and res[i][j] != 1): ????????????????return False; ????????????if (i != j and res[i][j] != 0): ????????????????return False; ????return True; # Driver Code 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)): ????print("Involutory Matrix"); else: ????print("Not Involutory Matrix"); # This code is contributed by mits ``` ## C# ```cs // C# Program to implement? // involutory matrix. using System; class GFG { ????static int N = 3; ????// Function for matrix multiplication. ????static void multiply(int [,]mat, int [,]res) ????{ ????????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. ????static bool InvolutoryMatrix(int [,]mat) ????{ ????????int [,]res = new int[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. ????public static void Main ()? ????{ ????????int [,]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.WriteLine( "Involutory Matrix"); ????????else ????????????Console.WriteLine( "Not Involutory Matrix"); ????} } // This code is contributed by vt_m ``` ## PHP ```php <?php // Program to implement? // involutory matrix. $N = 3; // Function for matrix // multiplication. function multiply($mat, $res) { ????global $N; ????for ($i = 0; $i < $N; $i++)? ????{ ????????for ($j = 0; $j < $N; $j++) ????????{ ????????????$res[$i][$j] = 0; ????????????for ($k = 0; $k < $N; $k++) ????????????????$res[$i][$j] += $mat[$i][$k] *? ????????????????????????????????$mat[$k][$j]; ????????} ????} ????return $res; } // Function to check // involutory matrix. function InvolutoryMatrix($mat) { ????global $N; ????$res; ????for ($i = 0; $i < $N; $i++) ????????for ($j = 0; $j < $N; $j++) ????????????$res[$i][$j] = 0; ????// multiply function call. ????$res = multiply($mat, $res); ????for ($i = 0; $i < $N; $i++)? ????{ ????????for ($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 $mat = array(array(1, 0, 0), ?????????????array(0, -1, 0), ?????????????array(0, 0, -1)); // Function call. If function? // return true then if part? // will execute otherwise // else part will execute. if (InvolutoryMatrix($mat)) ????echo "Involutory Matrix"; else ????echo "Not Involutory Matrix"; // This code is contributed by mits ?> ``` **輸出**: ``` Involutory Matrix ``` * * * * * *
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看