Aller au contenu

Mathc complexes/a349

Un livre de Wikilivres.


Décomposition d'une matrice en éléments propres

Installer et compiler ces fichiers dans votre répertoire de travail.


c00b.c
/* ------------------------------------ */
/*  save as :   c00b.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E        +1.E-0   
/* ------------------------------------ */       
/* ------------------------------------ */
void fun(int rc)
{
double **A    = rEcsymmetric_mZ(            i_mZ(rc,rc),99,1E-2);;
double **A_T  =   ctranspose_mZ(A,          i_mZ(rc,rc));

double **U    =          X_U_mZ(A_T,        i_mZ(rc,rc),FACTOR_E);
double **U_T  =   ctranspose_mZ(U,          i_mZ(rc,rc));

double **U_TA =          mul_mZ(U_T, A,     i_mZ(rc,rc));
double **X    =          mul_mZ(U_TA, U,    i_mZ(rc,rc));
            
double **LogX =       f_eigs_mZ(log,X,      i_mZ(rc,rc));
double **ULogX =         mul_mZ(U,LogX,     i_mZ(rc,rc));
double **LogA =          mul_mZ(ULogX,U_T,  i_mZ(rc,rc));

  clrscrn();
  printf(" A :");
  p_mZ(A, S9,P4, S8,P4, C4);
     
  printf(" U :");
  p_mZ(U, S9,P4, S8,P4, C4);
     
  printf(" X = U_T * A * U :");
  p_mZ(X, S11,P3, S7,P3, C4);
  stop(); 
   
  clrscrn();
  printf(" Copy/Past into the octave window.       \n\n");
  pE_Octave_mZ(A,"A",P4 ,P4);
  printf(" logm(A)\n\n\n");
  
  printf(" Log(A) = U Log(X) T_U :");
  p_mZ(LogA, S10,P4, S9,P4, C4);

   f_mZ(A);
   f_mZ(A_T);

   f_mZ(U);
   f_mZ(U_T);
   f_mZ(U_TA);
   f_mZ(X);
   
   f_mZ(LogX);
   f_mZ(ULogX);
   f_mZ(LogA);     
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun(R3);
    
} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :
 A :
  +2.7366 +0.0000i   -0.6200 +1.5474i   -0.8494 -0.0108i 
  -0.6200 -1.5474i   +2.0846 +0.0000i   -0.8766 -0.0597i 
  -0.8494 +0.0108i   -0.8766 +0.0597i   +1.9804 +0.0000i 

 U :
  -0.5050 -0.5371i   -0.1101 +0.3710i   +0.4831 -0.2711i 
  -0.3512 +0.4903i   -0.2329 -0.3767i   +0.5873 +0.3086i 
  +0.3048 -0.0000i   +0.8088 +0.0000i   +0.5029 -0.0000i 

 X = U_T * A * U :
     +4.320 -0.000i      +0.000 +0.000i      +0.000 -0.000i 
     +0.000 -0.000i      +2.371 +0.000i      -0.000 +0.000i 
     -0.000 +0.000i      -0.000 -0.000i      +0.110 -0.000i 

 Press return to continue. 


 Copy/Past into the octave window.       

 A=[
+2.7366e+00+0.0000e+00*i,-6.2000e-01+1.5474e+00*i,-8.4940e-01-1.0800e-02*i;
-6.2000e-01-1.5474e+00*i,+2.0846e+00+0.0000e+00*i,-8.7660e-01-5.9700e-02*i;
-8.4940e-01+1.0800e-02*i,-8.7660e-01+5.9700e-02*i,+1.9804e+00+0.0000e+00*i]

 logm(A)


 Log(A) = U Log(X) T_U :
   +0.2469  -0.0000i    -0.6661  +1.2087i    -0.8386  +0.3206i 
   -0.6661  -1.2087i    -0.2707  +0.0000i    -0.9715  -0.3871i 
   -0.8386  -0.3206i    -0.9715  +0.3871i    +0.1423  +0.0000i 


 Press   return to continue
 Press X return to stop