Aller au contenu

Mathc complexes/004

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[RCA*(RCA*C2)] ={   
+4,-53,-35,-14,-23,+37,
+58,+41,+65,-1,+6,+11,
+87,+6,-41,-97,+32,-63
};
                       
double **A         = ca_A_mZ(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);

  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);
  stop();
              
  f_mZ(A);
  f_mZ(V);  
  f_mZ(invV);  
  f_mZ(T);  
  f_mZ(EigsValue);
}
/* ------------------------------------ */
int main(void)
{
    fun();
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


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


 a=[
+4-53*i,-35-14*i,-23+37*i;
+58+41*i,+65-1*i,+6+11*i;
+87+6*i,-41-97*i,+32-63*i]

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


 V :
 -3.4790e-01 -3.5507e-01i  +3.8438e-02 +2.0039e-01i  +5.0800e-01 +2.1379e-01i 
 +1.6384e-01 +8.1577e-02i  -3.1879e-01 +4.1999e-01i  -4.2139e-02 -6.3360e-01i 
 +8.4817e-01 +0.0000e+00i  +8.2483e-01 +0.0000e+00i  +5.4130e-01 +0.0000e+00i 

 inv(V) ... Some time the matrix is not invertible :
 -5.7450e-01 +8.1654e-01i  +4.3646e-01 +2.9873e-01i  +5.4595e-01 -5.2619e-03i 
 +1.7040e-01 -7.5982e-01i  -5.3195e-01 -7.8327e-01i  +4.1540e-01 -3.7858e-02i 
 +6.4053e-01 -1.2164e-01i  +1.2668e-01 +7.2545e-01i  +3.5895e-01 +6.5932e-02i 

 Press return to continue. 


 A :
     +4.0000    -53.0000i     -35.0000    -14.0000i     -23.0000    +37.0000i 
    +58.0000    +41.0000i     +65.0000     -1.0000i      +6.0000    +11.0000i 
    +87.0000     +6.0000i     -41.0000    -97.0000i     +32.0000    -63.0000i 

 EigsValue = invV * A * V
 +2.3577e-01-1.2456e+02i  +0.0000e+00+0.0000e+00i  +0.0000e+00+0.0000e+00i 
 +0.0000e+00+0.0000e+00i  +9.9834e+01-2.4970e+01i  +0.0000e+00+0.0000e+00i 
 +0.0000e+00+0.0000e+00i  +0.0000e+00+0.0000e+00i  +9.2973e-01+3.2533e+01i 

 A = V * EigsValue * invV
     +4.0000    -53.0000i     -35.0000    -14.0000i     -23.0000    +37.0000i 
    +58.0000    +41.0000i     +65.0000     -1.0000i      +6.0000    +11.0000i 
    +87.0000     +6.0000i     -41.0000    -97.0000i     +32.0000    -63.0000i 

 Press return to continue.