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

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


c00c.c
/* ------------------------------------ */
/*  save as :   c00c.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E        +1.E-4   
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{  
        return(sin(2*x));
}
char  feq[] = "sin(2*x)";
/* ------------------------------------ */
double g(
double x)
{  
        return(2*sin(x)*cos(x));
}
char  geq[] = "2*sin(x)*cos(x)";
/* ------------------------------------ */
/* ------------------------------------ */
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 **sin2X       =      f_eigs_mZ(f,X,        i_mZ(rc,rc));
double **Usin2X      =         mul_mZ(U,sin2X,    i_mZ(rc,rc));
double **sin2        =         mul_mZ(Usin2X,U_T, i_mZ(rc,rc));

double **twocossinX  =  f_eigs_mZ(g,X,             i_mZ(rc,rc));
double **UtwocossinX =     mul_mZ(U,twocossinX,    i_mZ(rc,rc));
double **twocossin   =     mul_mZ(UtwocossinX,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(" sin(2*A)");
  p_mZ(sin2, S7,P3, S7,P3, C6);  
  printf(" 2*sin(A)*cos(A)");
  p_mZ(twocossin, 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(sin2X);
   f_mZ(Usin2X);
   f_mZ(sin2);

   f_mZ(twocossinX);
   f_mZ(UtwocossinX);
   f_mZ(twocossin);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
 +24523.0    +0.0i   +6476.0 +3989.0i   +6671.0 -2396.0i    -387.0 +4466.0i 
  +6476.0 -3989.0i  +17224.0    +0.0i   -4858.0  -977.0i   -2193.0 +4203.0i 
  +6671.0 +2396.0i   -4858.0  +977.0i   +9843.0    +0.0i   +6489.0 +3851.0i 
   -387.0 -4466.0i   -2193.0 -4203.0i   +6489.0 -3851.0i  +17903.0    +0.0i 

 U :
  -0.0580 +0.7967i   +0.1250 -0.1748i   -0.2763 -0.3911i   +0.2738 +0.1072i 
  +0.1589 +0.3895i   -0.5219 +0.0239i   +0.6355 -0.1105i   -0.2628 -0.2550i 
  -0.0463 +0.2147i   +0.5342 +0.0626i   -0.1227 +0.0880i   -0.6593 -0.4528i 
  +0.3698 -0.0000i   +0.6258 +0.0000i   +0.5761 +0.0000i   +0.3739 -0.0000i 

 X = U_T * A * U :
 +32494.043 +0.000i      -0.000 +0.000i      -0.000 -0.000i      -0.000 -0.000i 
     -0.000 -0.000i  +24492.608 -0.000i      -0.000 +0.000i      -0.000 -0.000i 
     -0.000 +0.000i      -0.000 -0.000i  +11038.621 -0.000i      -0.000 +0.000i 
     -0.000 +0.000i      -0.000 -0.000i      -0.000 -0.000i   +1467.728 -0.000i 

 Press return to continue. 


 sin(2*A)
 +0.477 -0.000i  +0.233 +0.527i  -0.003 -0.142i  +0.307 +0.406i 
 +0.233 -0.527i  +0.158 +0.000i  +0.145 +0.085i  -0.715 +0.115i 
 -0.003 +0.142i  +0.145 -0.085i  +0.908 -0.000i  +0.155 -0.097i 
 +0.307 -0.406i  -0.715 -0.115i  +0.155 +0.097i  +0.326 -0.000i 

 2*sin(A)*cos(A)
 +0.477 -0.000i  +0.233 +0.527i  -0.003 -0.142i  +0.307 +0.406i 
 +0.233 -0.527i  +0.158 +0.000i  +0.145 +0.085i  -0.715 +0.115i 
 -0.003 +0.142i  +0.145 -0.085i  +0.908 -0.000i  +0.155 -0.097i 
 +0.307 -0.406i  -0.715 -0.115i  +0.155 +0.097i  +0.326 -0.000i 


 Press   return to continue
 Press X return to stop