Aller au contenu

Mathc complexes/a337

Un livre de Wikilivres.


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-0  
/* ------------------------------------ */         
/* ------------------------------------ */
double f(
double x)
{  
        return(sinh(x)*sinh(x));
}
char  feq[] =  "sinh(x)*sinh(x)";
/* ------------------------------------ */
double g(
double x)
{  
        return(cosh(x)*cosh(x));
}
char  geq[] =  "cosh(x)*cosh(x)";
/* ------------------------------------ */
/* ------------------------------------ */
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 **sinh2X       =     f_eigs_mZ(f,X,         i_mZ(rc,rc));
double **Usinh2X      =        mul_mZ(U,sinh2X,    i_mZ(rc,rc));
double **sinh2        =        mul_mZ(Usinh2X,U_T, i_mZ(rc,rc));

double **cosh2X       =     f_eigs_mZ(g,X,         i_mZ(rc,rc));
double **Ucosh2X      =        mul_mZ(U,cosh2X,    i_mZ(rc,rc));
double **cosh2        =        mul_mZ(Ucosh2X,U_T, i_mZ(rc,rc));

double **cosh2mnssinh2 =       sub_mZ(cosh2,sinh2, 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(" cosh(A)**2");
  p_mZ(cosh2, S10,P3, S9,P3, C6);   
  printf(" sinh(A)**2");
  p_mZ(sinh2, S10,P3, S9,P3, C6);  
  printf(" cosh(A)**2 - sinh(A)**2");
  p_mZ(cosh2mnssinh2, S10,P3, S9,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(sinh2X);
   f_mZ(Usinh2X);
   f_mZ(sinh2);

   f_mZ(cosh2X);
   f_mZ(Ucosh2X);
   f_mZ(cosh2);
   
   f_mZ(cosh2mnssinh2);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
  +0.5451 +0.0000i   -0.4140 +0.7110i   +0.0845 +0.5988i 
  -0.4140 -0.7110i   +1.8853 +0.0000i   +1.6208 -0.5121i 
  +0.0845 -0.5988i   +1.6208 +0.5121i   +3.0687 +0.0000i 

 U :
  -0.0068 +0.2358i   +0.2280 -0.4493i   -0.6992 +0.4490i 
  +0.5474 -0.1878i   -0.5568 +0.2836i   -0.5100 -0.1206i 
  +0.7807 +0.0000i   +0.5963 +0.0000i   +0.1868 +0.0000i 

 X = U_T * A * U :
     +4.508 +0.000i      -0.000 +0.000i      -0.000 +0.000i 
     -0.000 -0.000i      +0.893 +0.000i      -0.000 -0.000i 
     +0.000 -0.000i      -0.000 +0.000i      +0.098 +0.000i 

 Press return to continue. 


 sinh(A)**2
  +114.843   -0.000i    -99.153 +263.323i    -10.872 +378.795i 
   -99.153 -263.323i   +690.088   +0.000i   +879.749 -301.726i 
   -10.872 -378.795i   +879.749 +301.726i  +1255.593   +0.000i 

 cosh(A)**2
  +115.843   -0.000i    -99.153 +263.323i    -10.872 +378.795i 
   -99.153 -263.323i   +691.088   -0.000i   +879.749 -301.726i 
   -10.872 -378.795i   +879.749 +301.726i  +1256.593   +0.000i 

 cosh(A)**2 - sinh(A)**2
    -1.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     -1.000   +0.000i 


 Press   return to continue
 Press X return to stop