Mathc matrices/c083a
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
|---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define Cb C1
/* ------------------------------------ */
void fun(int rc)
{
double **A = r_mR( i_mR(rc,rc),999.);
double **b = r_mR( i_mR(rc,Cb),999.);
double **InvA = inv_mR(A, i_mR(rc,rc));
double **X = mul_mR(InvA,b, i_mR(rc,Cb));
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");
stop();
clrscrn();
printf(" A:");
p_mR(A, S5,P0,C7);
printf(" b:");
p_mR(b, S5,P0,C7);
stop();
clrscrn();
printf(" inv(A):");
pE_mR(InvA, S1,P3,C7);
printf(" X = inv(A) b");
p_mR(X, S13,P4,C7);
stop();
clrscrn();
printf(" b:");
p_mR(b, S5,P0,C7);
printf(" AX:");
p_mR(mul_mR(A,X,b), S5,P0,C7);
f_mR(X);
f_mR(b);
f_mR(InvA);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC6)+RC1);
} 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 :
-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
B :
+596
+38
+44
-53
AX :
+596
+38
+44
-53
Press return to continue
Press X to stop