Étude du code


Installer et compiler ces fichiers dans votre répertoire de travail.


inv05.c
/* ------------------------------------ */
/*  Save as :   inv05.c                 */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **XX_invgj_pivot_mR(
double **Ab
)
{
double pivot = 1.;

int r= R1;

    while( pivot &&
          (r<Ab[R_SIZE  ][C0])
         )
       {
        pivot = pivotbestAId_mR(Ab,r);
        
        if(pivot>ERROR_E) 
                 zero_under_pivot_gj1Ab_mR(Ab,r);
        r++;
       }
       

  
    while( (r>R2) )
       {
		 r--; 
		 
  clrscrn();     
  printf("/* --------- DEBUG 1 ---------- */\n");	       
  printf(" Ab :           pivot[%d][[%d]",r,r);
  p_mR(Ab,S8,P4,C8);
  
         zero_below_pivot_gj1Ab_mR(Ab,r);
         
  printf(" Ab : zero_below_pivot_gj1Ab_mR(Ab,--r);");
  p_mR(Ab,S8,P4,C8);
  stop();
  clrscrn();
	    }
        

        
return(Ab);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **XX_invgj_mR(
double **A,
double **invA
)
{
double **ID = i_RC_mR(A[R_SIZE][C0],A[C_SIZE][C0]);
double **AID;

int r = A[R_SIZE][C0];

  r--;

  AID = i_Abr_Ac_bc_mR(r,r,r);

       eye_mR(ID);
  c_A_b_Ab_mR(A,ID,AID);
   XX_invgj_pivot_mR(AID);
    sort_c_mR(AID);
    sort_r_mR(AID);
   c_Inv_A_mR(AID,invA);

  f_mR(AID);
  f_mR(ID);

return(invA);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A   = r_mR( i_mR(r,r), 99.);
double **Inv =       i_mR(r,r);
double **AInv =      i_mR(r,r);

  clrscrn();
  
  printf(" A :");
  p_mR(A,S3,P0,C6);
  stop();  
  
  XX_invgj_mR(A,Inv);
 
  printf(" Copy/Past into the octave window.\n\n");
  printf("format short e\n");
  p_Octave_mR(A,"A",P0);
  
  printf(" inv(A)");
  pE_mR(Inv,S12,P4,C6);

  printf(" A * inv(A)");
  mul_mR(A,Inv,AInv);
  p_mR(AInv,S12,P4,C6);

  f_mR(AInv);
  f_mR(Inv);
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

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

} while(stop_w());

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


Cette fois ci, c'est les zéros aux dessus des pivots qui sont installés.


Exemple de sortie écran :
 ------------------------------------ 
 A :
+88 -45 -95 -55 
-85 -73 -77 -19 
-49 -45 +28 -63 
-83 +32 +76 -51 

 Press return to continue. 


/* --------- DEBUG 1 ---------- */
 Ab :           pivot[4][[4]
 +1.0000  -0.9263  +0.5789  +0.4737  -0.0000  -0.0105  -0.0000  -0.0000 
 -0.0000  +1.0000  -0.1636  +0.2337  -0.0000  +0.0052  -0.0000  -0.0064 
 -0.0000  -0.0000  +1.0000  +0.0109  -0.0000  -0.0089  -0.0103  +0.0008 
 -0.0000  -0.0000  -0.0000  +1.0000  -0.0192  +0.0063  +0.0165  +0.0015 

 Ab : zero_below_pivot_gj1Ab_mR(Ab,--r);
 +1.0000  -0.9263  +0.5789  +0.0000  +0.0091  -0.0135  -0.0078  -0.0007 
 +0.0000  +1.0000  -0.1636  +0.0000  +0.0045  +0.0037  -0.0038  -0.0068 
 +0.0000  +0.0000  +1.0000  +0.0000  +0.0002  -0.0090  -0.0105  +0.0008 
 -0.0000  -0.0000  -0.0000  +1.0000  -0.0192  +0.0063  +0.0165  +0.0015 

 Press return to continue. 


/* --------- DEBUG 1 ---------- */
 Ab :           pivot[3][[3]
 +1.0000  -0.9263  +0.5789  +0.0000  +0.0091  -0.0135  -0.0078  -0.0007 
 +0.0000  +1.0000  -0.1636  +0.0000  +0.0045  +0.0037  -0.0038  -0.0068 
 +0.0000  +0.0000  +1.0000  +0.0000  +0.0002  -0.0090  -0.0105  +0.0008 
 -0.0000  -0.0000  -0.0000  +1.0000  -0.0192  +0.0063  +0.0165  +0.0015 

 Ab : zero_below_pivot_gj1Ab_mR(Ab,--r);
 +1.0000  -0.9263  +0.0000  +0.0000  +0.0090  -0.0083  -0.0017  -0.0012 
 +0.0000  +1.0000  +0.0000  +0.0000  +0.0045  +0.0023  -0.0056  -0.0066 
 +0.0000  +0.0000  +1.0000  +0.0000  +0.0002  -0.0090  -0.0105  +0.0008 
 -0.0000  -0.0000  -0.0000  +1.0000  -0.0192  +0.0063  +0.0165  +0.0015 

 Press return to continue. 


/* --------- DEBUG 1 ---------- */
 Ab :           pivot[2][[2]
 +1.0000  -0.9263  +0.0000  +0.0000  +0.0090  -0.0083  -0.0017  -0.0012 
 +0.0000  +1.0000  +0.0000  +0.0000  +0.0045  +0.0023  -0.0056  -0.0066 
 +0.0000  +0.0000  +1.0000  +0.0000  +0.0002  -0.0090  -0.0105  +0.0008 
 -0.0000  -0.0000  -0.0000  +1.0000  -0.0192  +0.0063  +0.0165  +0.0015 

 Ab : zero_below_pivot_gj1Ab_mR(Ab,--r);
 +1.0000  +0.0000  +0.0000  +0.0000  +0.0132  -0.0062  -0.0069  -0.0073 
 +0.0000  +1.0000  +0.0000  +0.0000  +0.0045  +0.0023  -0.0056  -0.0066 
 +0.0000  +0.0000  +1.0000  +0.0000  +0.0002  -0.0090  -0.0105  +0.0008 
 -0.0000  -0.0000  -0.0000  +1.0000  -0.0192  +0.0063  +0.0165  +0.0015 

 Press return to continue. 



 Copy/Past into the octave window.

format short e
 A=[
+88,-45,-95,-55;
-85,-73,-77,-19;
-49,-45,+28,-63;
-83,+32,+76,-51]

 inv(A)
 +2.2515e-03  -6.6172e-03  +4.5301e-03  -5.5588e-03 
 +6.2632e-03  +1.5128e-03  -1.9241e-02  +1.6451e-02 
 -6.2066e-03  -7.3174e-03  +1.3189e-02  -6.8733e-03 
 -8.9834e-03  +8.1395e-04  +2.0933e-04  -1.0482e-02 

 A * inv(A)
     +1.0000      +0.0000      +0.0000      -0.0000 
     +0.0000      +1.0000      +0.0000      -0.0000 
     +0.0000      +0.0000      +1.0000      -0.0000 
     -0.0000      +0.0000      -0.0000      +1.0000 


 Press return to continue
 Press X      to stop