Aller au contenu

Mathc matrices/031

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_negative_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 : Definite negative");
  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 : Definite negative
    -24.32     -14.91      -0.76     +11.27 
    -14.91     -19.06      +0.86      +2.14 
     -0.76      +0.86     -38.72      +6.77 
    +11.27      +2.14      +6.77     -19.90 

 a : V * EValue * VT
    -24.32     -14.91      -0.76     +11.27 
    -14.91     -19.06      +0.86      +2.14 
     -0.76      +0.86     -38.72      +6.77 
    +11.27      +2.14      +6.77     -19.90 

 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