Aller au contenu

Mathc complexes/003

Un livre de Wikilivres.


Valeurs 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-2         
#define RCA          RC3  
/* ------------------------------------ */       
/* ------------------------------------ */
void fun(void)
{                          
double **A         = i_mZ(RCA,RCA);

double **V         = i_mZ(RCA,RCA);
double **invV      = i_mZ(RCA,RCA);
double **T         = i_mZ(RCA,RCA);

double **EigsValue = i_mZ(RCA,RCA);

   do
  {
	    r_mZ(A,99);
   eigs_V_mZ(A,V,FACTOR_E);
  }while(!det_Z(V).r);

  clrscrn();
  printf(" Copy/Past into the octave windows \n\n\n");
  p_Octave_mZ(A,"a",P0,P0);  
  printf(" [V, E]  = eigs (a,%d) \n\n\n",RCA);

  printf(" V :");
  eigs_V_mZ(A,V,FACTOR_E);  
  pE_mZ(V, S12,P4, S12,P4, C3);
  
  printf(" inv(V) ... Some time the matrix is not invertible :");
  pE_mZ(inv_mZ(V,invV), S12,P4, S12,P4, C3);
  stop();

  clrscrn(); 
  printf(" A :");
  p_mZ(A, S12,P4, S12,P4, C3);     
 
  printf(" EigsValue = invV * A * V");
  mul_mZ(invV,A,T);
  mul_mZ(T,V,EigsValue);
  pE_mZ(clean_eyes_mZ(EigsValue), S12,P4, S8,P4, C3); 
         
  printf(" A = V * EigsValue * invV");
  mul_mZ(V,EigsValue,T);
  mul_mZ(T,invV,A); 
  p_mZ(A, S12,P4, S12,P4, C3);
            
  f_mZ(A);
  f_mZ(V);  
  f_mZ(invV);  
  f_mZ(T);  
  f_mZ(EigsValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

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


Exemple de sortie écran :
 Copy/Past into the octave windows 


 a=[
-22+25*i,-47+89*i,-48-25*i;
+31+66*i,+70+40*i,-31-31*i;
-96-74*i,+24+20*i,+64+35*i]

 [V, E]  = eigs (a,3) 


 V :
 -4.4674e-01 -3.0474e-01i  +9.0931e-02 +1.6383e-01i  +6.6268e-01 -1.6290e-01i 
 -6.1976e-01 +1.2555e-01i  +4.9165e-02 -6.1701e-01i  -1.2247e-01 -8.2906e-02i 
 +5.5469e-01 +1.5396e-17i  +7.6274e-01 +0.0000e+00i  +7.1586e-01 +0.0000e+00i 

 inv(V) ... Some time the matrix is not invertible :
 -5.7718e-01 +1.6088e-01i  -6.7136e-01 -3.4078e-01i  +4.2231e-01 -4.1632e-01i 
 -4.8592e-01 -3.5016e-01i  +4.2316e-01 +9.5887e-01i  +4.9084e-01 +4.2661e-01i 
 +9.6498e-01 +2.4843e-01i  +6.9341e-02 -7.5761e-01i  +5.4671e-01 -1.3196e-01i 

 Press return to continue. 


 A :
    -22.0000    +25.0000i     -47.0000    +89.0000i     -48.0000    -25.0000i 
    +31.0000    +66.0000i     +70.0000    +40.0000i     -31.0000    -31.0000i 
    -96.0000    -74.0000i     +24.0000    +20.0000i     +64.0000    +35.0000i 

 EigsValue = invV * A * V
 +6.9321e+01+1.3043e+02i  +0.0000e+00+0.0000e+00i  +0.0000e+00+0.0000e+00i 
 +0.0000e+00+0.0000e+00i  +8.6175e+01-1.2567e+01i  +0.0000e+00+0.0000e+00i 
 +0.0000e+00+0.0000e+00i  +0.0000e+00+0.0000e+00i  -4.3497e+01-1.7858e+01i 

 A = V * EigsValue * invV
    -22.0000    +25.0000i     -47.0000    +89.0000i     -48.0000    -25.0000i 
    +31.0000    +66.0000i     +70.0000    +40.0000i     -31.0000    -31.0000i 
    -96.0000    -74.0000i     +24.0000    +20.0000i     +64.0000    +35.0000i 


 Press   return to continue
 Press X return to stop