Aller au contenu

Mathc complexes/a348

Un livre de Wikilivres.


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

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


c00a.c
/* ------------------------------------ */
/*  save as :   c00a.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 **ExpX =       f_eigs_mZ(exp,X,       i_mZ(rc,rc));
double **UExpX =         mul_mZ(U,ExpX,      i_mZ(rc,rc));
double **ExpA =          mul_mZ(UExpX,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, S9,P4, S8,P4, C4);
  stop(); 
   
  clrscrn();
  printf(" Copy/Past into the octave window.       \n\n");
  pE_Octave_mZ(A,"A",P4 ,P4);
  printf(" expm(A)\n\n\n");
  
  printf(" Exp(A) = U Exp(X) T_U :");
  p_mZ(ExpA, 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(ExpX);
   f_mZ(UExpX);
   f_mZ(ExpA);   
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
  +1.5722 +0.0000i   -0.5899 +0.6995i   -0.0471 +0.0117i 
  -0.5899 -0.6995i   +1.2184 +0.0000i   -0.6906 -0.3813i 
  -0.0471 -0.0117i   -0.6906 +0.3813i   +1.2535 +0.0000i 

 U :
  +0.5813 -0.2305i   -0.5865 +0.2258i   +0.4335 -0.1617i 
  -0.5924 -0.3212i   -0.1167 -0.0699i   +0.6342 +0.3538i 
  +0.3935 +0.0000i   +0.7659 +0.0000i   +0.5085 +0.0000i 

 X = U_T * A * U :
  +2.5281 -0.0000i   -0.0000 -0.0000i   +0.0000 -0.0000i 
  +0.0000 +0.0000i   +1.4330 +0.0000i   +0.0000 -0.0000i 
  -0.0000 -0.0000i   +0.0000 -0.0000i   +0.0830 +0.0000i 

 Press return to continue. 


 Copy/Past into the octave window.       

 A=[
+1.5722e+00+0.0000e+00*i,-5.8990e-01+6.9950e-01*i,-4.7100e-02+1.1700e-02*i;
-5.8990e-01-6.9950e-01*i,+1.2184e+00+0.0000e+00*i,-6.9060e-01-3.8130e-01*i;
-4.7100e-02-1.1700e-02*i,-6.9060e-01+3.8130e-01*i,+1.2535e+00+0.0000e+00*i]

 expm(A)


 Exp(A) = U Exp(X) T_U :
   +6.7869  -0.0000i    -2.9299  +3.4899i    +1.2228  -0.5009i 
   -2.9299  -3.4899i    +6.3406  +0.0000i    -2.9449  -1.6125i 
   +1.2228  +0.5009i    -2.9449  +1.6125i    +4.6795  +0.0000i 


 Press   return to continue
 Press X return to stop