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-4   
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{  
         return(cos(2*x));
}
char  feq[] =  "cos(2*x)";
/* ------------------------------------ */
double g(
double x)
{  
         return(2*cos(x)*cos(x)-1);
}
char  geq[] =  "2*cos(x)**2-1";
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int rc)
{
double **A           = rcsymmetric_mZ(            i_mZ(rc,rc),99);
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 **cos2X       =      f_eigs_mZ(f,X,        i_mZ(rc,rc));
double **Ucos2X      =         mul_mZ(U,cos2X,    i_mZ(rc,rc));
double **cos2        =         mul_mZ(Ucos2X,U_T, i_mZ(rc,rc));

double **twocosP2mns1X  =  f_eigs_mZ(g,X,        i_mZ(rc,rc));
double **UtwocosP2mns1X =     mul_mZ(U,twocosP2mns1X,    i_mZ(rc,rc));
double **twocosP2mns1   =     mul_mZ(UtwocosP2mns1X,U_T, i_mZ(rc,rc));

  clrscrn();
  printf(" A :");
  p_mZ(A, S9,P1, S8,P1, 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(" cos(2*A)");
  p_mZ(cos2, S7,P3, S7,P3, C6);  
  printf(" 2*cos(A)*cos(A)-1");
  p_mZ(twocosP2mns1, S7,P3, S7,P3, C6);      
     
   f_mZ(A);
   f_mZ(A_T);

   f_mZ(U);
   f_mZ(U_T);
   f_mZ(U_TA);
   f_mZ(X);

   f_mZ(cos2X);
   f_mZ(Ucos2X);
   f_mZ(cos2);

   f_mZ(twocosP2mns1X);
   f_mZ(UtwocosP2mns1X);
   f_mZ(twocosP2mns1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
 +20901.0    +0.0i   -5124.0 +8398.0i   +1911.0-12822.0i    +637.0 -6614.0i 
  -5124.0 -8398.0i  +29876.0    +0.0i   +2664.0 -2146.0i   -4089.0 -1659.0i 
  +1911.0+12822.0i   +2664.0 +2146.0i  +16912.0    +0.0i   -1352.0  -649.0i 
   +637.0 +6614.0i   -4089.0 +1659.0i   -1352.0  +649.0i  +11944.0    +0.0i 

 U :
  +0.2214 -0.5933i   -0.3956 +0.1038i   -0.0226 -0.1500i   +0.0252 +0.6388i 
  -0.6878 +0.0260i   -0.2692 -0.5440i   +0.3003 -0.0300i   -0.1699 +0.1945i 
  +0.2617 +0.0065i   -0.1668 -0.6516i   -0.3269 +0.1211i   +0.5914 -0.0886i 
  +0.2380 +0.0000i   +0.1093 +0.0000i   +0.8743 +0.0000i   +0.4087 +0.0000i 

 X = U_T * A * U :
 +39150.644 +0.000i      +0.000 +0.000i      -0.000 +0.000i      -0.000 -0.000i 
     +0.000 -0.000i  +27612.736 +0.000i      -0.000 +0.000i      -0.000 -0.000i 
     -0.000 -0.000i      -0.000 +0.000i  +12130.233 -0.000i      +0.000 +0.000i 
     +0.000 +0.000i      -0.000 -0.000i      +0.000 -0.000i    +739.387 +0.000i 

 Press return to continue. 


 cos(2*A)
 +0.013 +0.000i  -0.279 +0.642i  +0.074 -0.130i  +0.072 -0.367i 
 -0.279 -0.642i  +0.156 +0.000i  -0.484 +0.008i  +0.030 -0.005i 
 +0.074 +0.130i  -0.484 -0.008i  -0.472 -0.000i  -0.204 +0.132i 
 +0.072 +0.367i  +0.030 +0.005i  -0.204 -0.132i  +0.299 +0.000i 

 2*cos(A)*cos(A)-1
 +0.013 +0.000i  -0.279 +0.642i  +0.074 -0.130i  +0.072 -0.367i 
 -0.279 -0.642i  +0.156 +0.000i  -0.484 +0.008i  +0.030 -0.005i 
 +0.074 +0.130i  -0.484 -0.008i  -0.472 -0.000i  -0.204 +0.132i 
 +0.072 +0.367i  +0.030 +0.005i  -0.204 -0.132i  +0.299 +0.000i 


 Press   return to continue
 Press X return to stop