Mathc matrices/h09l
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : vgj1piv.h */
double pivotbest_gj1Ab_mR(
double **Ab,
int pv
double pvbest = fabs(Ab[pv][pv]);
int best_r = pv;
int best_c = pv;
int r;
int c;
 for ( r=pv; r<Ab[R_SIZE][C0]; r++)
 for ( c=pv; c<Ab[R_SIZE][C0]; c++)
 if(fabs(Ab[r][c])>pvbest)
 pvbest = fabs(Ab[r][c]);
 best_r = r;
 best_c = c;
 if(best_r!=pv) swapR_mR(Ab,pv,best_r);
 if(best_c!=pv) swapC_withR0_mR(Ab,pv,best_c);
 return(pvbest);
/* ------------------------------------ */
double **zero_under_pivot_gj1Ab_mR(
double **Ab,
int pv
double pivot = Ab[pv][pv];
int r;
 if(fabs(pivot)>ERROR_E)
 mulR_mR( Ab,(1./pivot),pv); 
 for( r=(pv+C1); r<Ab[R_SIZE][C0]; r++)
 addR_mR( Ab,(-Ab[r][pv]),pv,r);

return(Ab);
/* ------------------------------------ */
double **zero_below_pivot_gj1Ab_mR(
double **Ab,
int pv
int r;
 if(fabs(Ab[pv][pv])>ERROR_E)
 for( r=(pv-R1); r>=R1; r--)
 addR_mR( Ab,(-Ab[r][pv]),pv,r);
return(Ab);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc matrices/h09m
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : vgpivaid.h */
double pivotbestAId_mR(
double **AId,
int pv
double pivotbest = fabs(AId[pv][pv]);
int best_r = pv;
int best_c = pv;
int r;
int c;
 for ( r=pv; r<AId[R_SIZE][C0]; r++)
 for ( c=pv; c<AId[R_SIZE][C0]; c++) 
 if(fabs(AId[r][c])>pivotbest)
 pivotbest = fabs(AId[r][c]);
 best_r = r;
 best_c = c;
 c--;
 if(best_r!=pv) swapR_mR (AId,pv, best_r );
 if(best_c!=pv) { swapC_withR0_mR(AId,pv, best_c );
 return(pivotbest);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc matrices/h09n
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : vgjinv.h */
double **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 **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);
 sort_r_mR(AID);
 c_Inv_A_mR(AID,invA);
 f_mR(AID);
 f_mR(ID);
return(invA);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc matrices/c091a
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : inv_r.c */
void fun(int r)
double **A = i_mR(r,r);
double **Inv = i_mR(r,r);
 clrscrn();
 printf(" A\n");
 p_mR(r_mR(A,9999.),S8,P0,C6);
 stop();
 clrscrn();
 printf(" invgj_mR(A,invA); gauss jordan (AId)\n");
 pE_mR(invgj_mR(A,Inv),S12,P4,C6);
 printf(" inv_mR(A,Inv); det...,adjoint... \n");
 pE_mR(inv_mR(A,Inv),S12,P4,C6);
 stop();
 clrscrn();
 printf(" Copy/Past into the octave window.\n\n");
 p_Octave_mR(A,"A",P0);
 printf(" inv(A)\n");
 pE_mR(Inv,S12,P4,C6);
 f_mR(Inv);
 f_mR(A);
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
do
 fun(rp_I(C2)+C4);
} while(stop_w());
 return 0;
/* ------------------------------------ */

Exemple de sortie écran :
 A
 -57 +6812 +5568 
 +5330 +1020 +7124 
 +8836 -4887 -1189 
 Press return to continue. 
 invgj_mR(A,invA); gauss jordan (AId)
 +1.2226e-04 -6.9537e-05 +1.5591e-04 
 +2.5209e-04 -1.7876e-04 +1.0946e-04 
 -1.2757e-04 +2.1799e-04 -1.3232e-04 
 inv_mR(A,Inv); det...,adjoint... 
 +1.2226e-04 -6.9537e-05 +1.5591e-04 
 +2.5209e-04 -1.7876e-04 +1.0946e-04 
 -1.2757e-04 +2.1799e-04 -1.3232e-04 
 Press return to continue. 
 Copy/Past into the octave window.
 A=[
-57,+6812,+5568;
+5330,+1020,+7124;
+8836,-4887,-1189]
 inv(A)
 +1.2226e-04 -6.9537e-05 +1.5591e-04 
 +2.5209e-04 -1.7876e-04 +1.0946e-04 
 -1.2757e-04 +2.1799e-04 -1.3232e-04 
 Press return to continue
 Press X to stop

Mathc matrices/c092a
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : c01a.c */
void fun(int r)
double **A = i_mR(r,r);
double **Inv = i_mR(r,r);
double **B = r_mR(i_mR(r,C1),999.);
double **X = i_mR(r,C1);
double **T = i_mR(r,C1);
 do
 r_mR(A,999.);
 printf(".");
 }while(!det_R(A));
 clrscrn();
 printf(" We want to find X such as, \n\n");
 printf(" AX = B \n\n");
 printf(" If A is a square matrix and, \n\n");
 printf(" If A has an inverse matrix, \n\n");
 printf(" you can find X by this method\n\n");
 printf(" X = inv(A) B \n\n\n");
 printf(" To verify the result you can \n\n");
 printf(" multiply the matrix A by X. \n\n");
 printf(" You must refind B. \n\n");
 getchar();
 clrscrn();
 printf(" A :\n");
 p_mR(A,S5,P0,C7);
 printf(" B :\n");
 p_mR(B,S5,P0,C7);
 getchar();
 clrscrn();
 printf(" inv(A) :\n");
 pE_mR(invgj_mR(A,Inv),S1,P3,C7);
 printf(" X = inv(A) * B :\n");
 p_mR(mul_mR(Inv,B,X),S13,P4,C7);
 getchar();
 clrscrn();
 printf(" B :\n");
 p_mR(B,S5,P0,C7);
 printf(" AX :\n");
 p_mR(mul_mR(A,X,T),S5,P0,C7);
 f_mR(T);
 f_mR(X);
 f_mR(B);
 f_mR(Inv);
 f_mR(A);
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
do
 fun(rp_I(C2)+C4);
} while(stop_w());
 return 0;
/* ------------------------------------ */

Exemple de sortie écran :
 We want to find X such as, 
 AX = B 
 If A is a square matrix and, 
 If A has an inverse matrix, 
 you can find X by this method
 X = inv(A) B 
 To verify the result you can 
 multiply the matrix A by X. 
 You must refind B. 
 ------------------------------------ 
 A :
 +920 +812 +480 +958 +816 +756 +290 
 -205 -827 +364 +536 -797 +276 +928 
 -857 -823 +326 -113 +628 -217 +202 
 +436 +210 -567 +100 -429 +502 +958 
 -219 -619 +568 -857 -431 +766 -815 
 -965 +522 -105 +888 -349 -187 -425 
 +864 +462 +72 -721 -5 -397 -553 
 B :
 -945 
 +220 
 -217 
 -141 
 -71 
 -117 
 -609 
 ------------------------------------ 
 inv(A) :
-8.906e-05 +9.175e-05 -1.423e-03 -1.117e-03 -3.734e-04 -1.130e-03 -9.295e-04 
+5.131e-04 +6.253e-06 +1.784e-03 +1.821e-03 +3.771e-04 +1.659e-03 +2.255e-03 
+6.736e-04 +8.201e-04 +1.812e-03 +9.064e-04 +4.654e-04 +1.241e-03 +2.322e-03 
-6.188e-05 +9.859e-05 -1.556e-03 -1.460e-03 -5.000e-04 -7.340e-04 -1.664e-03 
+1.755e-04 -5.191e-04 +1.693e-04 -2.473e-04 -1.711e-04 -4.417e-04 -5.540e-04 
+2.294e-04 -3.508e-04 -1.845e-04 +3.526e-04 +5.538e-04 -1.024e-04 -6.624e-04 
+2.916e-04 +3.833e-04 +1.664e-03 +1.547e-03 +4.814e-05 +8.175e-04 +1.576e-03 
 X = inv(A) * B :
 +1.2954 
 -2.7215 
 -2.5695 
 +1.7586 
 +0.1193 
 +0.0724 
 -1.8290

B :
 -945 
 +220 
 -217 
 -141 
 -71 
 -117 
 -609 
 AX :
 -945 
 +220 
 -217 
 -141 
 -71 
 -117 
 -609 
 Press return to continue
 Press X to stop