Aller au contenu

Mathc complexes/a343

Un livre de Wikilivres.


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-0   
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{  
         return(cosh(2*x));
}
char  feq[] =  "cosh(2*x)";
/* ------------------------------------ */
double g(
double x)
{  
         return(2*cosh(x)*cosh(x)-1);
}
char  geq[] =  "2*cosh(x)**2-1";
/* ------------------------------------ */
/* ------------------------------------ */
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 **cosh2X          = f_eigs_mZ(f,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 **twocoshP2mns1X  = f_eigs_mZ(g,X,                 i_mZ(rc,rc));
double **UtwocoshP2mns1X =    mul_mZ(U,twocoshP2mns1X,    i_mZ(rc,rc));
double **twocoshP2mns1   =    mul_mZ(UtwocoshP2mns1X,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(" cosh(2*A)");
  p_mZ(cosh2, S11,P3, S10,P3, C6);  
  printf(" 2*cosh(A)**2-1");
  p_mZ(twocoshP2mns1, S11,P3, S10,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(cosh2X);
   f_mZ(Ucosh2X);
   f_mZ(cosh2);

   f_mZ(twocoshP2mns1X);
   f_mZ(UtwocoshP2mns1X);
   f_mZ(twocoshP2mns1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 A :
  +1.2336 +0.0000i   +0.0033 -0.1194i   -0.2293 -0.2944i 
  +0.0033 +0.1194i   +1.7050 +0.0000i   -0.3979 -0.2889i 
  -0.2293 +0.2944i   -0.3979 +0.2889i   +0.6411 +0.0000i 

 U :
  -0.2341 -0.0562i   -0.2679 -0.8575i   +0.1940 +0.3120i 
  -0.6466 -0.6103i   +0.0404 +0.3253i   +0.2746 +0.1631i 
  +0.3893 -0.0000i   +0.2923 +0.0000i   +0.8735 +0.0000i 

 X = U_T * A * U :
  +1.9354 -0.0000i   -0.0000 -0.0000i   +0.0000 -0.0000i 
  -0.0000 +0.0000i   +1.3383 +0.0000i   +0.0000 +0.0000i 
  -0.0000 +0.0000i   +0.0000 -0.0000i   +0.3060 -0.0000i 

 Press return to continue. 


 cosh(2*A)
     +7.446    +0.000i      +2.463    -2.109i      -2.556    -2.030i 
     +2.463    +2.109i     +19.879    +0.000i      -5.668    -4.837i 
     -2.556    +2.030i      -5.668    +4.837i      +5.171    +0.000i 

 2*cosh(A)**2-1
     +7.446    +0.000i      +2.463    -2.109i      -2.556    -2.030i 
     +2.463    +2.109i     +19.879    -0.000i      -5.668    -4.837i 
     -2.556    +2.030i      -5.668    +4.837i      +5.171    +0.000i 


 Press   return to continue
 Press X return to stop