Étude du code


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


inv10.c
/* ------------------------------------ */
/*  Save as :   inv10.c                 */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **xx_sort_r_mR(
double **Ab
)
{
double pivot;
int c;
int r;
int r_pivot = R1;


    for ( c=C1; c<Ab[C_SIZE_A][C0]; c++)
      {
              r = r_pivot;
          pivot = 0.;
          
      while( (pivot<ERROR_E) && r<Ab[R_SIZE][C0] )
         {
          pivot = fabs( Ab[r][c] );

          if(pivot>ERROR_E) 
           {
              swapR_mR(Ab, r, r_pivot);
              r_pivot++;
            }           
          r++;
         }
       }
       
 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);
   invgj_pivot_mR(AID);
    sort_c_mR(AID);
    xx_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();

  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;
}
/* ------------------------------------ */
/* ------------------------------------ */


Nous allons voir une nouvelle fonction, sort_r_mR(); que nous appellerons xx_sort_r_mR();


Exemple de sortie écran :
 ------------------------------------ 
 Copy/Past into the octave window.

format short e
 A=[
-75,+52,-57;
+30,+22,+20;
-91,-45,-57]

 inv(A)
 +2.1673e-02  -3.3850e-01  -1.4044e-01 
 +6.7344e-03  +5.5834e-02  +1.2857e-02 
 -3.9917e-02  +4.9633e-01  +1.9652e-01 

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


 Press return to continue
 Press X      to stop