Gauss-Jordan


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  = i_mR(r,r);
double **b  = i_mR(r,C1);
double **Ab = i_Abr_Ac_bc_mR(r,   r,  C1);
/*            i_Abr_Ac_bc_mR(R_Ab,C_A,C_b));  */
double **x  = i_mR(r,C1);
double **Ax = i_mR(r,C1);

 do
  {
   r_mR(A,999.);
   printf(".");
  }while(!det_R(A));

  clrscrn();
  printf(" A :");
  p_mR(A,S8,P0,C7);
  
  printf(" b :");
  r_mR(b,999.);
  p_mR(b,S8,P0,C7);
  
  printf(" Ab :");
  c_A_b_Ab_mR(A,b,Ab);
  p_mR(Ab,S8,P0,C7);
  stop();

  clrscrn();
  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf("\n rref(Ab,.00000000001)\n\n");
  printf("  gj_TP_mR(Ab) :");
  gj_TP_mR(Ab);
  p_mR(Ab,S10,P4,C7);
  stop();  
  
  clrscrn();
  printf(" b :");
  p_mR(b,S10,P4,C7); 
  
  printf(" A * x = b :");
  c_c_mR(Ab,r+C1,x,C1);
  mul_mR(A,x,Ax); 
  p_mR(Ax,S10,P4,C7);  


  f_mR(Ab);
  f_mR(b);
  f_mR(A);
  f_mR(x);
  f_mR(Ax);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
do
{
  fun(rp_I(RC5)+R1);


} while(stop_w());

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


Nous utilisons la fonction gj_TP_mR(Ab); pour résoudre ce système.


Exemple de sortie écran :
 A :
    -574     +470     -646     -561     -661 
    +732     +314       -6     +855     -584 
    +589     -926      -73     -503     -255 
    -575     -799     +899      -95     -346 
    +883     -449     +746     +832     +162 

 b :
    +600 
    -807 
    -216 
    +436 
    +327 

 Ab :
    -574     +470     -646     -561     -661     +600 
    +732     +314       -6     +855     -584     -807 
    +589     -926      -73     -503     -255     -216 
    -575     -799     +899      -95     -346     +436 
    +883     -449     +746     +832     +162     +327 

 Press return to continue. 



 Copy/Past into the octave window.

 Ab=[
-574,+470,-646,-561,-661,+600;
+732,+314,-6,+855,-584,-807;
+589,-926,-73,-503,-255,-216;
-575,-799,+899,-95,-346,+436;
+883,-449,+746,+832,+162,+327]


 rref(Ab,.00000000001)

  gj_TP_mR(Ab) :
   +1.0000    +0.0000    +0.0000    +0.0000    +0.0000    +5.4681 
   +0.0000    +1.0000    +0.0000    +0.0000    +0.0000    +8.4701 
   +0.0000    +0.0000    +1.0000    +0.0000    +0.0000   +10.0007 
   -0.0000    -0.0000    -0.0000    +1.0000    +0.0000    -9.5533 
   -0.0000    -0.0000    -0.0000    +0.0000    +1.0000    -1.2993 

 Press return to continue. 



 b :
 +600.0000 
 -807.0000 
 -216.0000 
 +436.0000 
 +327.0000 

 A * x = b :
 +600.0000 
 -807.0000 
 -216.0000 
 +436.0000 
 +327.0000 


 Press   return to continue
 Press X return to stop