Aller au contenu

Mathc complexes/01c

Un livre de Wikilivres.

Application

Installer et compiler ce fichier 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
  {
   rupper_mZ(A,99);
   eigs_V_mZ(A,V,FACTOR_E);
  }while(!det_Z(V).r||!det_Z(V).i);

  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(invgj_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);
  p_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;
}
/* ------------------------------------ */
/* ------------------------------------ */


Valeurs propres vecteurs propres d'une matrice triangulaire supérieur


Remarque :

  • Je n'ai pas les même vecteurs propres que octave.
  • Mais je parviens cependant à calculer les valeurs propres (EigsValue = invV * A * V), et a retrouver la matrice A (A = V * EigsValue * invV).


Exemple de sortie écran :

 Copy/Past into the octave windows 


 a=[
+81+75*i,+67+75*i,-85+55*i;
+0+0*i,+72-84*i,+47-40*i;
+0+0*i,+0+0*i,+45+35*i]

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


 V :
 +1.0000e+00 +0.0000e+00i  -4.1766e-01 +3.3265e-01i  +5.2434e-01 -6.4251e-01i 
 -1.2484e-14 +1.5986e-14i  +8.4552e-01 +0.0000e+00i  -2.0190e-01 -1.5113e-01i 
 -1.3416e-14 -5.0590e-14i  +0.0000e+00 +0.0000e+00i  +4.9864e-01 -5.5360e-17i 

 inv(V) ... Some time the matrix is not invertible :
 +1.0000e+00 -3.2697e-14i  +4.9397e-01 -3.9342e-01i  -7.3229e-01 +1.2789e+00i 
 +3.0548e-15 +1.0129e-14i  +1.1827e+00 +3.8015e-15i  +4.7888e-01 +3.5846e-01i 
 +2.6904e-14 +1.0146e-13i  +5.3205e-14 +3.9531e-14i  +2.0055e+00 -3.9664e-14i 

 Press return to continue. 


 A :
    +81.0000    +75.0000i     +67.0000    +75.0000i     -85.0000    +55.0000i 
     +0.0000     +0.0000i     +72.0000    -84.0000i     +47.0000    -40.0000i 
     +0.0000     +0.0000i      +0.0000     +0.0000i     +45.0000    +35.0000i 

 EigsValue = invV * A * V
    +81.0000+75.0000i      +0.0000 +0.0000i      +0.0000 +0.0000i 
     +0.0000 +0.0000i     +72.0000-84.0000i      +0.0000 +0.0000i 
     +0.0000 +0.0000i      +0.0000 +0.0000i     +45.0000+35.0000i 

 A = V * EigsValue * invV
    +81.0000    +75.0000i     +67.0000    +75.0000i     -85.0000    +55.0000i 
     +0.0000     -0.0000i     +72.0000    -84.0000i     +47.0000    -40.0000i 
     +0.0000     -0.0000i      -0.0000     -0.0000i     +45.0000    +35.0000i 


 Press   return to continue
 Press X return to stop