Aller au contenu

Mathc matrices/02s

Un livre de Wikilivres.


Application

Installer et compiler ces fichiers dans votre répertoire de travail.

c00a.c
/* ------------------------------------ */
/*  Save as :  c00a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A      =  rdefinite_positive_mR( i_mR(r,r), 99);
double **a      =                         i_mR(r,r);

double **V      =                         i_mR(r,r);
double **VT     =                         i_mR(r,r);
double **EValue =                         i_mR(r,r);

double **T1     =                         i_mR(r,r);

  clrscrn();
  printf(" A = Q D QT: ");
  p_mR(A,S10,P2,C6);  

  eigs_V_mR(A,V); 
  transpose_mR(V,VT); 
    
/* EValue = VT * A * V */ 
  mul_mR(VT,A,T1);
  mul_mR(T1,V,EValue);   
 
  printf(" A : V * EValue * VT");
  mul_mR(V,EValue,T1);
  mul_mR(T1,VT,a);    
  p_mR(a,S10,P2,C6);  
  
  printf(" A - a = 0"); 
  sub_mR(A,a,T1); 
  p_mR(T1,S10,P2,C6);  
   
  f_mR(A);
  f_mR(a);
    
  f_mR(V);
  f_mR(VT);
  
  f_mR(EValue);  
     
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(R3)+R1);

} while(stop_w());

  return 0;
}

/* ------------------------------------ */
/* ------------------------------------ */


Vérifions que A = V * EValue * VT

Exemple de sortie écran :

 A :
    +31.20     +14.83     +10.49      +6.04 
    +14.83     +29.02     +13.07      +1.63 
    +10.49     +13.07     +43.52     +19.58 
     +6.04      +1.63     +19.58     +38.26 

 A : V * EValue * VT
    +31.20     +14.83     +10.49      +6.04 
    +14.83     +29.02     +13.07      +1.63 
    +10.49     +13.07     +43.52     +19.58 
     +6.04      +1.63     +19.58     +38.26 

 A - a = 0
     -0.00      -0.00      -0.00      -0.00 
     -0.00      -0.00      -0.00      -0.00 
     -0.00      -0.00      +0.00      +0.00 
     -0.00      -0.00      +0.00      -0.00 


 Press   return to continue
 Press X return to stop