Mathc matrices/c092b
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : c01b.c */
void fun(int r)
double **A = i_mR(r,r);
double **Inv = i_mR(r,r);
double **B = r_mR(i_mR(r,C6),999.);
double **X = i_mR(r,C6);
double **T = i_mR(r,C6);
 do
 r_mR(A,999.);
 printf(".");
 }while(!det_R(A));
 clrscrn();
 printf(" \n");
 printf(" Linear systems with common coefficient matrix.\n\n");
 printf(" Ax1=b1 \n");
 printf(" Ax2=b2 \n");
 printf(" ... \n");
 printf(" Axn=bn \n\n");
 printf(" We can write these equalities in this maner. \n\n");
 printf(" A|x1|x2|...|xn| = b1|b2|...|bn| \n\n");
 printf(" or simply : \n\n");
 printf(" AX = B \n\n");
 printf(" where B = b1|b2|...|bn \n\n");
 printf(" and X = x1|x2|...|xn \n\n");
 getchar();
 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,C6);
 printf(" b1 b2 ... bn :\n");
 p_mR(B,S9,P0,C6);
 getchar();
 clrscrn();
 printf(" inv(A) :\n");
 pE_mR(invgj_mR(A,Inv),S1,P4,C6);
 printf(" X = inv(A) * B :\n\n");
 printf(" x1 x2 ... xn\n");
 p_mR(mul_mR(Inv,B,X),S9,P4,C6);
 getchar();
 clrscrn();
 printf(" b1 b2 ... bn :\n");
 p_mR(B,S9,P0,C6);
 printf(" Ax1 Ax2 ... Axn :\n");
 p_mR(mul_mR(A,X,T),S9,P0,C6);
 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 :
 ------------------------------------ 
 Linear systems with common coefficient matrix.
 Ax1=b1 
 Ax2=b2 
 Axn=bn 
 We can write these equalities in this maner. 
 A|x1|x2|...|xn| = b1|b2|...|bn| 
 or simply : 
 AX = B 
 where B = b1|b2|...|bn 
 and X = x1|x2|...|xn 
 ------------------------------------ 
 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 :
 -805 -853 +866 -331 
 -883 +580 -427 +110 
 +946 -289 -15 -461 
 +762 -203 -307 +224 
 b1 b2 ... bn :
 +508 +648 -861 +186 -515 -755 
 -189 -845 +462 -45 -29 +74 
 +378 +424 -711 -887 +750 +374 
 +820 +6 +598 -383 -689 +108 
 ------------------------------------ 
 inv(A) :
-5.3070e-04 -8.6702e-04 +3.1954e-05 -2.9268e-04 
-1.2603e-03 -1.0402e-03 -3.5923e-04 -2.0908e-03 
-6.8572e-04 -2.2335e-03 -1.0293e-03 -2.0348e-03 
-2.7663e-04 -1.0544e-03 -1.8449e-03 +7.7635e-04 
 X = inv(A) * B :
 x1 x2 ... xn
 -0.3337 +0.4005 -0.1414 +0.0241 +0.5241 +0.3169 
 -2.2939 -0.1026 -0.3903 +0.9318 +1.8504 +0.5144 
 -1.9838 +0.9944 -0.9265 +1.6653 +1.0479 -0.2523 
 -0.0020 -0.0659 +1.5271 +1.3351 -1.7456 -0.4753 
 ------------------------------------ 
 b1 b2 ... bn :
 +508 +648 -861 +186 -515 -755 
 -189 -845 +462 -45 -29 +74 
 +378 +424 -711 -887 +750 +374 
 +820 +6 +598 -383 -689 +108 
 Ax1 Ax2 ... Axn :
 +508 +648 -861 +186 -515 -755 
 -189 -845 +462 -45 -29 +74 
 +378 +424 -711 -887 +750 +374 
 +820 +6 +598 -383 -689 +108 
 Press return to continue
 Press X to stop

Mathc matrices/a10
Étude du code
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : f01.c */
/* ------------------------------------ */ 
void XX_p_freeV(
double **b,
int e,
int d)
 int m;
 int r;
 int c;
char v;
 m = 0;
 for(r=R1; r<b[R_SIZE][C0]; r++)
 v = 'y' - (b[R_SIZE][C0]-C1);
 printf("\n");
 m++;
 printf(" x%d = ",m);
 for(c=C1; c<b[C_SIZE][C0]; c++)
 if(c==C1) printf(" %+*.*f",e,d,b[r][c]);
 else
 if(fabs(b[r][c])>ERROR_E) printf(" %+*.*f*%c",e,d,b[r][c],v);
 else printf(" %+*.*f*%c",e,d,0.,v);
 v++;
 printf("\n");
/* ------------------------------------ */
int main(void)
double ab[R4*C7]={
 +1, -3, +4, -2, +5, +4, 0,
 +2, -6, +9, -1, +8, +2, 0,
 +2, -6, +9, -1, +9, +7, 0, 
 -1, 3, -4, 2, -5, -4, 0, 
double **Ab = ca_A_mR(ab,i_Abr_Ac_bc_mR(R4,C6,C1));
double **A = c_Ab_A_mR(Ab,i_mR(R4,C6));
double **b = c_Ab_b_mR(Ab,i_mR(R4,C1));
double **Ab_free = i_Abr_Ac_bc_mR(csize_A_R(Ab),csize_A_R(Ab),C1+C3);
double **b_free = i_mR(rsize_R(Ab_free),csize_b_R(Ab_free)); 
int r;
 clrscrn();
 printf(" Ab :");
 p_mR(Ab,S6,P1,C10);
 printf(" Ab : gj_PP_mR(Ab,NO) :");
 gj_PP_mR(Ab,NO);
 p_mR(Ab,S6,P1,C10);
 stop();
 clrscrn(); 
 put_var_mR(Ab,Ab_free); 
 printf(" Ab_free : put_var_mR(Ab,Ab_free);"); 
 p_mR(Ab_free,S6,P1,C10); 
 stop();
 clrscrn(); 
 put_freeV_mR(Ab_free);
 printf(" Ab_free : put_freeV_mR(Ab_free);"); 
 p_mR(Ab_free,S6,P1,C10); 
 stop();
 clrscrn(); 
 r = rsize_R(Ab_free);
 while(r>R1) 
 zero_below_pivot_gj1Ab_mR(Ab_free,r--);
 printf(" Ab_free : zero_below_pivot_gj1Ab_mR(Ab_free,r--);"); 
 p_mR(Ab_free,S6,P1,C10); 
 stop(); 
 clrscrn();
 c_Ab_b_mR(Ab_free,b_free);
 printf(" b_free :"); 
 p_mR(b_free,S10,P0,C7);
 printf(" b_free : free variables");
 XX_p_freeV(b_free,S8,P0);
 stop();
 f_mR(Ab);
 f_mR(Ab_free);
 f_mR(b_free);
 f_mR(b);
 f_mR(A);
 return 0;
/* ------------------------------------ */

Exemple de sortie écran :
 Ab :
 +1.0 -3.0 +4.0 -2.0 +5.0 +4.0 +0.0 
 +2.0 -6.0 +9.0 -1.0 +8.0 +2.0 +0.0 
 +2.0 -6.0 +9.0 -1.0 +9.0 +7.0 +0.0 
 -1.0 +3.0 -4.0 +2.0 -5.0 -4.0 +0.0 
 Ab : gj_PP_mR(Ab,NO) :
 +1.0 -3.0 +4.5 -0.5 +4.0 +1.0 +0.0 
 -0.0 -0.0 +1.0 +3.0 -2.0 -6.0 -0.0 
 +0.0 +0.0 +0.0 +0.0 +1.0 +5.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 
 Press return to continue. 
 ------------------------------------ 
 Ab_free : put_var_mR(Ab,Ab_free);
 +1.0 -3.0 +4.5 -0.5 +4.0 +1.0 +0.0 +0.0 +0.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 
 -0.0 -0.0 +1.0 +3.0 -2.0 -6.0 -0.0 +0.0 +0.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +1.0 +5.0 +0.0 +0.0 +0.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 
 Press return to continue. 
 ------------------------------------ 
 Ab_free : put_freeV_mR(Ab_free);
 +1.0 -3.0 +4.5 -0.5 +4.0 +1.0 +0.0 +0.0 +0.0 +0.0 
 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 
 -0.0 -0.0 +1.0 +3.0 -2.0 -6.0 -0.0 +0.0 +0.0 +0.0 
 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +1.0 +5.0 +0.0 +0.0 +0.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +1.0 
 Press return to continue. 
 ------------------------------------ 
 Ab_free : zero_below_pivot_gj1Ab_mR(Ab_free,r--);
 +1.0 +0.0 +0.0 +0.0 +0.0 +0.0 +0.0 +3.0 +14.0 +37.0 
 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 
 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 +0.0 -3.0 -4.0 
 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 
 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +0.0 -5.0 
 +0.0 +0.0 +0.0 +0.0 +0.0 +1.0 +0.0 +0.0 +0.0 +1.0 
 Press return to continue. 
 b_free :
 +0 +3 +14 +37 
 +0 +1 +0 +0 
 +0 +0 -3 -4 
 +0 +0 +1 +0 
 +0 +0 +0 -5 
 +0 +0 +0 +1 
 b_free : free variables
 x1 = +0 +3*s +14*t +37*u
 x2 = +0 +1*s +0*t +0*u
 x3 = +0 +0*s -3*t -4*u
 x4 = +0 +0*s +1*t +0*u
 x5 = +0 +0*s +0*t -5*u
 x6 = +0 +0*s +0*t +1*u
 Press return to continue.