Maison  >  Article  >  développement back-end  >  Une matrice carrée peut-elle être exprimée comme la somme d’une matrice symétrique et d’une matrice antisymétrique ?

Une matrice carrée peut-elle être exprimée comme la somme d’une matrice symétrique et d’une matrice antisymétrique ?

WBOY
WBOYavant
2023-09-13 17:05:021197parcourir

Une matrice carrée peut-elle être exprimée comme la somme d’une matrice symétrique et d’une matrice antisymétrique ?

Matrice symétrique - Une matrice dont la transposée est égale à la matrice elle-même. On l'appelle alors une matrice symétrique.

Matrice antisymétrique - Sa transposée est égale à la valeur négative de la matrice, elle est alors appelée matrice antisymétrique.

La somme d'une matrice symétrique et d'une matrice antisymétrique est une matrice carrée. Pour trouver la somme de ces matrices nous avons la formule suivante.

Supposons que A soit une matrice carrée. Alors,

A = (½)*(A + A`)+ (½ )*(A - A`),

A` est la transposée de la matrice.

(½ )(A+ A`) est une matrice symétrique.

(½ )(A - A`) est une matrice antisymétrique.

Exemple

#include <bits/stdc++.h>
using namespace std;
#define N 3
void printMatrix(float mat[N][N]) {
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++)
         cout << mat[i][j] << " ";
         cout << endl;
   }
}
int main() {
   float mat[N][N] = { { 2, -2, -4 },
   { -1, 3, 4 },
   { 1, -2, -3 } };
   float tr[N][N];
   for (int i = 0; i < N; i++)
   for (int j = 0; j < N; j++)
   tr[i][j] = mat[j][i];
   float symm[N][N], skewsymm[N][N];
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         symm[i][j] = (mat[i][j] + tr[i][j]) / 2;
         skewsymm[i][j] = (mat[i][j] - tr[i][j]) / 2;
      }
   }
   cout << "Symmetric matrix-" << endl;
   printMatrix(symm);
   cout << "Skew Symmetric matrix-" << endl;
   printMatrix(skewsymm);
   return 0;
}

Sortie

Symmetric matrix -
2 -1.5 -1.5
-1.5 3 1
-1.5 1 -3
Skew Symmetric matrix -
0 -0.5 -2.5
0.5 0 3
2.5 -3 0

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer