Aller au contenu

Mathc matrices/020

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 rc)
{
double **A      =         r_mR(    i_mR(rc,rc),9);
double **Q      =                  i_mR(rc,rc);
double **R      =                  i_mR(rc,rc);	

double **A_T    = transpose_mR(A,  i_mR(rc,rc));
double **Q_T    =                  i_mR(rc,rc);
double **R_T    =                  i_mR(rc,rc);	

  clrscrn();
  printf(" A : ");
  p_mR(A,S4,P0,C4);
  QR_mR(A,Q,R);    
  printf(" Q :");
  p_mR(Q,S8,P3,C4);  
  printf(" R :");
  p_mR(R,S8,P3,C4);
  stop();
  
  clrscrn();
  printf(" A_T : ");
  p_mR(A_T,S4,P0,C4);
  QR_mR(A_T,Q_T,R_T);    
  printf(" Q_T :");
  p_mR(Q_T,S8,P3,C4);  
  printf(" R_T :");
  p_mR(R_T,S8,P3,C4);
  stop();

  clrscrn();
  printf(" Q :");
  p_mR(Q,S8,P3,C4);  
  printf(" R :");
  p_mR(R,S8,P3,C4);   
  printf(" Q_T :");
  p_mR(Q_T,S8,P3,C4);  
  printf(" R_T :");
  p_mR(R_T,S8,P3,C4);
  stop();
    
  clrscrn();
  printf(" A :");
  p_mR(A,S3,P0,C4); 
  printf(" A = Q * R  :");  
  mul_mR(Q,R, A);
  p_mR(A,S8,P3,C4);  

  printf(" A_T :");
  p_mR(A_T,S3,P0,C4); 
  printf(" A_T = Q_T * R_T  :");  
  mul_mR(Q_T,R_T, A_T);
  p_mR(A_T,S8,P3,C4); 
       
  f_mR(A);
  f_mR(Q);
  f_mR(R);
  f_mR(A_T);
  f_mR(Q_T);
  f_mR(R_T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
   do 
         fun(rp_I(RC3)+RC1);
        
    while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :

 A : 
  +8   +5   -9 
  +1   -8   -4 
  +5   +3   +8 

 Q :
  +0.843   +0.096   -0.529 
  +0.105   -0.994   -0.012 
  +0.527   +0.045   +0.849 

 R :
  +9.487   +4.954   -3.795 
  -0.000   +8.571   +3.477 
  +0.000   +0.000  +11.598 

 Press return to continue. 


 A_T : 
  +8   +1   +5 
  +5   -8   +3 
  -9   -4   +8 

 Q_T :
  +0.614   +0.090   +0.784 
  +0.383   -0.902   -0.196 
  -0.690   -0.421   +0.588 

 R_T :
 +13.038   +0.307   -1.304 
  +0.000   +8.995   -5.625 
  +0.000   +0.000   +8.041 

 Press return to continue. 


 Q :
  +0.843   +0.096   -0.529 
  +0.105   -0.994   -0.012 
  +0.527   +0.045   +0.849 

 R :
  +9.487   +4.954   -3.795 
  -0.000   +8.571   +3.477 
  +0.000   +0.000  +11.598 

 Q_T :
  +0.614   +0.090   +0.784 
  +0.383   -0.902   -0.196 
  -0.690   -0.421   +0.588 

 R_T :
 +13.038   +0.307   -1.304 
  +0.000   +8.995   -5.625 
  +0.000   +0.000   +8.041 

 Press return to continue. 


 A :
 +8  +5  -9 
 +1  -8  -4 
 +5  +3  +8 

 A = Q * R  :
  +8.000   +5.000   -9.000 
  +1.000   -8.000   -4.000 
  +5.000   +3.000   +8.000 

 A_T :
 +8  +1  +5 
 +5  -8  +3 
 -9  -4  +8 

 A_T = Q_T * R_T  :
  +8.000   +1.000   +5.000 
  +5.000   -8.000   +3.000 
  -9.000   -4.000   +8.000 


 Press   return to continue
 Press X return to stop