Mathc matrices/c092a
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c01a.c |
---|
/* ------------------------------------ */
/* Save as : c01a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
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