Aller au contenu

Mathc complexes/00q

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"
/* ------------------------------------ */
void fun(int rc)
{
double **A      =         r_mZ(    i_mZ(rc,rc),9);
double **Q      =                  i_mZ(rc,rc);
double **R      =                  i_mZ(rc,rc);	

double **A_T    = transpose_mZ(A,  i_mZ(rc,rc));
double **Q_T    =                  i_mZ(rc,rc);
double **R_T    =                  i_mZ(rc,rc);	

  clrscrn();
  printf(" A : ");
  p_mZ(A, S8,P4, S8,P4, C6);
  QR_mZ(A,Q,R);    
  printf(" Q :");
  p_mZ(Q, S8,P4, S8,P4, C6);  
  printf(" R :");
  p_mZ(R, S8,P4, S8,P4, C6);
  stop();
  
  clrscrn();
  printf(" A_T : Transpose");
  p_mZ(A_T, S8,P4, S8,P4, C6);
  QR_mZ(A_T,Q_T,R_T);    
  printf(" Q_T :");
  p_mZ(Q_T, S8,P4, S8,P4, C6);  
  printf(" R_T :");
  p_mZ(R_T, S8,P4, S8,P4, C6);
  stop();

  clrscrn();
  printf(" Q :");
  p_mZ(Q, S8,P4, S8,P4, C6);  
  printf(" R :");
  p_mZ(R, S8,P4, S8,P4, C6);   
  printf(" Q_T :");
  p_mZ(Q_T, S8,P4, S8,P4, C6);  
  printf(" R_T :");
  p_mZ(R_T, S8,P4, S8,P4, C6);
  stop();
    
  clrscrn();
  printf(" A :");
  p_mZ(A, S8,P4, S8,P4, C6); 
  printf(" A = Q * R  :");  
  mul_mZ(Q,R, A);
  p_mZ(A, S8,P4, S8,P4, C6);  

  printf(" A_T :");
  p_mZ(A_T, S8,P4, S8,P4, C6); 
  printf(" A_T = Q_T * R_T  :");  
  mul_mZ(Q_T,R_T, A_T);
  p_mZ(A_T, S8,P4, S8,P4, C6); 
       
  f_mZ(A);
  f_mZ(Q);
  f_mZ(R);
  f_mZ(A_T);
  f_mZ(Q_T);
  f_mZ(R_T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

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


La QR décomposition d'une matrice et de sa transposée non aucun lien.

Exemple de sortie écran :

 A : 
 +7.0000 -6.0000i  -4.0000 +2.0000i  -4.0000 +5.0000i 
 -7.0000 -2.0000i  -4.0000 +2.0000i  +5.0000 +6.0000i 
 -4.0000 -3.0000i  +8.0000 +9.0000i  -2.0000 -8.0000i 

 Q :
 +0.5483 -0.4700i  +0.0714 +0.0959i  -0.1945 +0.6530i 
 -0.5483 -0.1567i  -0.5675 -0.0688i  -0.5285 +0.2624i 
 -0.3133 -0.2350i  +0.5920 +0.5555i  -0.3981 -0.1709i 

 R :
+12.7671 -0.0000i  -5.8745 -3.4463i  -5.7178 +0.3916i 
 -0.0000 -0.0000i +11.7734 +0.0000i  -8.6839 -5.9451i 
 -0.0000 -0.0000i  -0.0000 +0.0000i  +5.1380 -0.0000i 

 Press return to continue. 


 A_T : Transpose
 +7.0000 -6.0000i  -7.0000 -2.0000i  -4.0000 -3.0000i 
 -4.0000 +2.0000i  -4.0000 +2.0000i  +8.0000 +9.0000i 
 -4.0000 +5.0000i  +5.0000 +6.0000i  -2.0000 -8.0000i 

 Q_T :
 +0.5793 -0.4966i  -0.3081 +0.3602i  -0.4394 -0.0073i 
 -0.3310 +0.1655i  -0.7383 -0.1024i  -0.1983 +0.5178i 
 -0.3310 +0.4138i  +0.1590 +0.4410i  -0.6494 -0.2787i 

 R_T :
+12.0830 -0.0000i  -0.5793 -8.6899i  -4.6346 -4.5518i 
 +0.0000 -0.0000i  +7.6257 +0.0000i -10.5223 -3.8506i 
 +0.0000 +0.0000i  +0.0000 +0.0000i  +8.3818 -0.0000i 

 Press return to continue. 


 Q :
 +0.5483 -0.4700i  +0.0714 +0.0959i  -0.1945 +0.6530i 
 -0.5483 -0.1567i  -0.5675 -0.0688i  -0.5285 +0.2624i 
 -0.3133 -0.2350i  +0.5920 +0.5555i  -0.3981 -0.1709i 

 R :
+12.7671 -0.0000i  -5.8745 -3.4463i  -5.7178 +0.3916i 
 -0.0000 -0.0000i +11.7734 +0.0000i  -8.6839 -5.9451i 
 -0.0000 -0.0000i  -0.0000 +0.0000i  +5.1380 -0.0000i 

 Q_T :
 +0.5793 -0.4966i  -0.3081 +0.3602i  -0.4394 -0.0073i 
 -0.3310 +0.1655i  -0.7383 -0.1024i  -0.1983 +0.5178i 
 -0.3310 +0.4138i  +0.1590 +0.4410i  -0.6494 -0.2787i 

 R_T :
+12.0830 -0.0000i  -0.5793 -8.6899i  -4.6346 -4.5518i 
 +0.0000 -0.0000i  +7.6257 +0.0000i -10.5223 -3.8506i 
 +0.0000 +0.0000i  +0.0000 +0.0000i  +8.3818 -0.0000i 

 Press return to continue. 


 A :
 +7.0000 -6.0000i  -4.0000 +2.0000i  -4.0000 +5.0000i 
 -7.0000 -2.0000i  -4.0000 +2.0000i  +5.0000 +6.0000i 
 -4.0000 -3.0000i  +8.0000 +9.0000i  -2.0000 -8.0000i 

 A = Q * R  :
 +7.0000 -6.0000i  -4.0000 +2.0000i  -4.0000 +5.0000i 
 -7.0000 -2.0000i  -4.0000 +2.0000i  +5.0000 +6.0000i 
 -4.0000 -3.0000i  +8.0000 +9.0000i  -2.0000 -8.0000i 

 A_T :
 +7.0000 -6.0000i  -7.0000 -2.0000i  -4.0000 -3.0000i 
 -4.0000 +2.0000i  -4.0000 +2.0000i  +8.0000 +9.0000i 
 -4.0000 +5.0000i  +5.0000 +6.0000i  -2.0000 -8.0000i 

 A_T = Q_T * R_T  :
 +7.0000 -6.0000i  -7.0000 -2.0000i  -4.0000 -3.0000i 
 -4.0000 +2.0000i  -4.0000 +2.0000i  +8.0000 +9.0000i 
 -4.0000 +5.0000i  +5.0000 +6.0000i  -2.0000 -8.0000i 


 Press   return to continue
 Press X return to stop