Aller au contenu

Mathc complexes/a325

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-4   
/* ------------------------------------ */         
/* ------------------------------------ */
double f(
double x)
{  
        return(sin(x)*sin(x));
}
char  feq[] =  "sin(x)*sin(x)";
/* ------------------------------------ */
double g(
double x)
{  
        return(cos(x)*cos(x));
}
char  geq[] =  "cos(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 **cos2X       =      f_eigs_mZ(g,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 **sin2plscos2 =         add_mZ(sin2,cos2,  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(A)**2");
  p_mZ(sin2, S7,P3, S7,P3, C6);  
  printf(" cos(A)**2");
  p_mZ(cos2, S7,P3, S7,P3, C6);      
  printf(" cos(A)**2 + sin(A)**2");
  p_mZ(sin2plscos2, 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(cos2X);
   f_mZ(Ucos2X);
   f_mZ(cos2);
   
   f_mZ(sin2plscos2);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
  +5283.0    +0.0i  -10648.0  -900.0i   -4476.0 -4046.0i   +1446.0 -3578.0i 
 -10648.0  +900.0i  +37332.0    +0.0i   +3824.0 -6367.0i   +8514.0  +378.0i 
  -4476.0 +4046.0i   +3824.0 +6367.0i  +25766.0    +0.0i   +4848.0+15400.0i 
  +1446.0 +3578.0i   +8514.0  -378.0i   +4848.0-15400.0i  +18666.0    +0.0i 

 U :
  -0.1151 -0.1547i   +0.3229 -0.0146i   +0.0551 +0.0366i   -0.8583 +0.3424i 
  +0.6728 +0.1747i   -0.5618 -0.3195i   -0.0551 +0.0436i   -0.2934 +0.0903i 
  +0.1919 +0.4863i   +0.0873 +0.5606i   -0.1448 -0.5925i   -0.0559 +0.1722i 
  +0.4543 +0.0000i   +0.3948 -0.0000i   +0.7865 +0.0000i   +0.1381 +0.0000i 

 X = U_T * A * U :
 +50803.134 -0.000i      +0.000 +0.000i      -0.000 -0.000i      -0.000 -0.000i 
     +0.000 -0.000i  +30498.660 +0.000i      -0.000 +0.000i      -0.000 -0.000i 
     -0.000 +0.000i      -0.000 -0.000i   +5532.599 +0.000i      +0.000 +0.000i 
     -0.000 +0.000i      -0.000 +0.000i      +0.000 -0.000i    +212.608 +0.000i 

 Press return to continue. 


 sin(A)**2
 +0.628 +0.000i  +0.185 -0.031i  +0.058 +0.099i  -0.092 +0.023i 
 +0.185 +0.031i  +0.159 +0.000i  +0.059 -0.021i  +0.022 +0.025i 
 +0.058 -0.099i  +0.059 +0.021i  +0.099 +0.000i  +0.003 +0.029i 
 -0.092 -0.023i  +0.022 -0.025i  +0.003 -0.029i  +0.091 -0.000i 

 cos(A)**2
 +0.372 +0.000i  -0.185 +0.031i  -0.058 -0.099i  +0.092 -0.023i 
 -0.185 -0.031i  +0.841 +0.000i  -0.059 +0.021i  -0.022 -0.025i 
 -0.058 +0.099i  -0.059 -0.021i  +0.901 +0.000i  -0.003 -0.029i 
 +0.092 +0.023i  -0.022 +0.025i  -0.003 +0.029i  +0.909 -0.000i 

 cos(A)**2 + sin(A)**2
 +1.000 +0.000i  +0.000 +0.000i  -0.000 -0.000i  -0.000 +0.000i 
 +0.000 -0.000i  +1.000 +0.000i  -0.000 -0.000i  -0.000 +0.000i 
 -0.000 +0.000i  -0.000 +0.000i  +1.000 +0.000i  -0.000 +0.000i 
 -0.000 -0.000i  -0.000 -0.000i  -0.000 -0.000i  +1.000 -0.000i 


 Press   return to continue
 Press X return to stop