Mathc matrices/c09a02
Étude du code
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : inv02.c */
/* ------------------------------------ */
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);
clrscrn();
printf("/* --------- DEBUG 1 ---------- */\n");
 eye_mR(ID);
printf(" ID : eye_mR(ID);");
p_mR(ID,S3,P0,C6);
stop();
clrscrn();
printf(" A :");
p_mR(A,S3,P0,C6);
printf(" ID :");
p_mR(ID,S3,P0,C6);
printf(" AID :");
p_mR(AID,S3,P0,C6);
printf("/* --------- DEBUG 2 ---------- */\n");
 c_A_b_Ab_mR(A,ID,AID);
printf(" AID : c_A_b_Ab_mR(A,ID,AID);");
p_mR(AID,S3,P0,C10); 
stop();
clrscrn(); 
printf("/* --------- DEBUG 3 ---------- */\n");
 invgj_pivot_mR(AID);
printf(" AID : invgj_pivot_mR(AID);");
p_mR(AID,S6,P6,C6); 
stop();
clrscrn();
printf(" AID : \n");
pall_mR(AID,S6,P6,C8);
printf("/* --------- DEBUG 4 ---------- */\n\n\n");
 sort_c_mR(AID);
printf(" AID : sort_c_mR(AID);\n");
pall_mR(AID,S6,P6,C8); 
stop();
clrscrn();
printf(" AID :");
p_mR(AID,S6,P6,C6); 
printf("/* --------- DEBUG 5 ---------- */\n\n");
 sort_r_mR(AID);
printf(" AID : sort_r_mR(AID);");
p_mR(AID,S6,P6,C6); 
stop();
clrscrn();
printf(" AID : ");
p_mR(AID,S6,P6,C6); 
printf("/* --------- DEBUG 6 ---------- */\n");
 c_Inv_A_mR(AID,invA);
printf(" invA : c_Inv_A_mR(AID,invA);");
p_mR(invA,S6,P6,C6); 
stop(); 
clrscrn(); 
 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(C3);
} while(stop_w());
 return 0;
/* ------------------------------------ */

Dans DEBUG 4 on utilise la fonction pall_mR(); pour afficher la colonne zéro et voir l'index des colonnes.

Exemple de sortie écran :
 A :
-57 +34 +66 
-61 +42 -21 
-75 -95 -35 
 Press return to continue. 
/* --------- DEBUG 1 ---------- */
 ID : eye_mR(ID);
 +1 +0 +0 
 +0 +1 +0 
 +0 +0 +1 
 Press return to continue. 
 A :
-57 +34 +66 
-61 +42 -21 
-75 -95 -35 
 ID :
 +1 +0 +0 
 +0 +1 +0 
 +0 +0 +1 
 AID :
 +0 +0 +0 +0 +0 +0 
 +0 +0 +0 +0 +0 +0 
 +0 +0 +0 +0 +0 +0 
/* --------- DEBUG 2 ---------- */
 AID : c_A_b_Ab_mR(A,ID,AID);
-57 +34 +66 +1 +0 +0 
-61 +42 -21 +0 +1 +0 
-75 -95 -35 +0 +0 +1 
 Press return to continue. 
/* --------- DEBUG 3 ---------- */
 AID : invgj_pivot_mR(AID);
+1.000000 +0.000000 +0.000000 +0.009033 -0.000728 -0.006793 
-0.000000 +1.000000 +0.000000 -0.006607 -0.004507 -0.004534 
+0.000000 +0.000000 +1.000000 -0.010360 +0.011634 -0.000416 
 Press return to continue. 
 AID : 
+4.000000 +2.000000 +1.000000 +3.000000 +5.000000 +4.000000 +6.000000 <- index colonnes
+7.000000 +1.000000 +0.000000 +0.000000 +0.009033 -0.000728 -0.006793 
+4.000000 -0.000000 +1.000000 +0.000000 -0.006607 -0.004507 -0.004534 
+0.000000 +0.000000 +0.000000 +1.000000 -0.010360 +0.011634 -0.000416 
/* --------- DEBUG 4 ---------- */
 AID : sort_c_mR(AID);
+4.000000 +1.000000 +2.000000 +3.000000 +4.000000 +5.000000 +6.000000 
+7.000000 +0.000000 +1.000000 +0.000000 -0.000728 +0.009033 -0.006793 
+4.000000 +1.000000 -0.000000 +0.000000 -0.004507 -0.006607 -0.004534 
+0.000000 +0.000000 +0.000000 +1.000000 +0.011634 -0.010360 -0.000416 
 Press return to continue. 
 AID :
+0.000000 +1.000000 +0.000000 -0.000728 +0.009033 -0.006793 
+1.000000 -0.000000 +0.000000 -0.004507 -0.006607 -0.004534 
+0.000000 +0.000000 +1.000000 +0.011634 -0.010360 -0.000416 
/* --------- DEBUG 5 ---------- */
 AID : sort_r_mR(AID);
+1.000000 -0.000000 +0.000000 -0.004507 -0.006607 -0.004534 
+0.000000 +1.000000 +0.000000 -0.000728 +0.009033 -0.006793 
+0.000000 +0.000000 +1.000000 +0.011634 -0.010360 -0.000416 
 Press return to continue. 
 AID : 
+1.000000 -0.000000 +0.000000 -0.004507 -0.006607 -0.004534 
+0.000000 +1.000000 +0.000000 -0.000728 +0.009033 -0.006793 
+0.000000 +0.000000 +1.000000 +0.011634 -0.010360 -0.000416 
/* --------- DEBUG 6 ---------- */
 invA : c_Inv_A_mR(AID,invA);
-0.004507 -0.006607 -0.004534 
-0.000728 +0.009033 -0.006793 
+0.011634 -0.010360 -0.000416 
 Press return to continue. 
 Copy/Past into the octave window.
format short e
 A=[
-57,+34,+66;
-61,+42,-21;
-75,-95,-35]
 inv(A)
 -4.5068e-03 -6.6074e-03 -4.5341e-03 
 -7.2837e-04 +9.0331e-03 -6.7934e-03 
 +1.1634e-02 -1.0360e-02 -4.1621e-04 
 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

Mathc matrices/c09a03
Étude du code
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : inv03.c */
/* ------------------------------------ */
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>R1) )
 r--;
 zero_below_pivot_gj1Ab_mR(Ab,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);
 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();
 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 étudier la fonction invgj_pivot_mR();. Comme cette fonction existe dans la bibliothèque, nous allons l'appeler XX_invgj_pivot_mR();

Exemple de sortie écran :
 Copy/Past into the octave window.
format short e
 A=[
-81,-13,+40;
+70,+64,+78;
+64,+76,+54]
 inv(A)
 -1.0590e-02 +1.6030e-02 -1.5310e-02 
 +5.1920e-03 -2.9704e-02 +3.9060e-02 
 +5.2434e-03 +2.2807e-02 -1.8309e-02 
 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

Mathc matrices/c09a04
Étude du code
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : inv04.c */
/* ------------------------------------ */
double **XX_invgj_pivot_mR(
double **Ab
double pivot = 1.;
int r= R1;
 while( pivot &&
 (r<Ab[R_SIZE ][C0])
 {
 clrscrn(); 
printf("/* --------- DEBUG 1 ---------- */\n"); 
 printf(" inv(A)\n");
 p_mR(Ab,S8,P4,C8);
 pivot = pivotbestAId_mR(Ab,r);
 printf(" pivot[%d][[%d] = %f\n",r,r,pivot);
 printf(" inv(A)\n");
 p_mR(Ab,S8,P4,C8);
 stop();
 if(pivot>ERROR_E) 
 zero_under_pivot_gj1Ab_mR(Ab,r);
 r++;

clrscrn();
printf(" inv(A)\n");
p_mR(Ab,S8,P4,C8); 
stop();
clrscrn();
 while( (r>R1) )
 r--;
 zero_below_pivot_gj1Ab_mR(Ab,r);