Mathc matrices/c083a
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(inv_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(RC6)+RC1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Nous résolvons un système d'équations, et nous vérifions les calculs. 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 :
-317 +796 +360 -229
-481 +296 +276 -323
+140 -259 +922 -701
+372 +124 -519 -729
B :
+596
+38
+44
-53
--------------------------------------
inv(A) :
+9.981e-04 -2.381e-03 +4.803e-04 +2.795e-04
+1.510e-03 -9.396e-04 -2.211e-04 +1.547e-04
+5.547e-04 -6.148e-04 +7.184e-04 -5.927e-04
+3.712e-04 -9.370e-04 -3.040e-04 -7.809e-04
X = inv(A) * B :
+0.5107
+0.8461
+0.3703
+0.2136
-------------------------------------- Ax = B ?
B :
+596
+38
+44
-53
AX :
+596
+38
+44
-53
Press return to continue
Press X to stop