Aller au contenu

Mathc matrices/01y

Un livre de Wikilivres.


Matrices triangulaires


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      = rlower_mR(i_mR(r,r),9.);
double **Q      =           i_mR(r,r);
double **R      =           i_mR(r,r);

  clrscrn();
  printf(" A :");
  P_mR(A,S3,P0,C4); 

  printf(" Copy/Past into the octave windows \n\n");
  p_Octave_mR(A,"a",P0);
  printf(" [Q, R] = qr (a,0) \n\n");
  stop();
 
  clrscrn();
  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 :");
  p_mR(A,S3,P0,C4); 
  
  printf(" A = Q * R  :");  
  mul_mR(Q,R, A);
  p_mR(A,S8,P3,C4);  
  
  f_mR(A);
  f_mR(Q);
  f_mR(R);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :

 A :
 -8,  +0,  +0,  +0, 
 -3,  -7,  +0,  +0, 
 -5,  -8,  +4,  +0, 
 +2,  +8,  +7,  -5  

 Copy/Past into the octave windows 

 a=[
-8,+0,+0,+0;
-3,-7,+0,+0;
-5,-8,+4,+0;
+2,+8,+7,-5]

 [Q, R] = qr (a,0) 

 Press return to continue. 


 Q :
  -0.792   +0.554   -0.253   -0.044 
  -0.297   -0.434   +0.126   -0.841 
  -0.495   -0.388   +0.621   +0.468 
  +0.198   +0.595   +0.731   -0.268 

 R :
 +10.100   +7.624   -0.594   -0.990 
  +0.000  +10.903   +2.617   -2.976 
  -0.000   -0.000   +7.603   -3.657 
  +0.000   -0.000   +0.000   +1.338 

 Press return to continue. 


 A :
 -8  +0  +0  +0 
 -3  -7  +0  +0 
 -5  -8  +4  +0 
 +2  +8  +7  -5 

 A = Q * R  :
  -8.000   -0.000   -0.000   +0.000 
  -3.000   -7.000   -0.000   +0.000 
  -5.000   -8.000   +4.000   -0.000 
  +2.000   +8.000   +7.000   -5.000 


 Press   return to continue
 Press X return to stop