Mathc matrices/a185
Installer et compiler ces fichiers dans votre répertoire de travail.
c01a.c |
---|
/* ------------------------------------ */
/* Save as : c01a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R3
#define CA C3
#define Cb C3
/* ------------------------------------ */
int main(void)
{
double a[RA*CA] ={ 4,2,3,
5,3,1,
8,2,2};
double b[RA*Cb] ={ 3, 4, 9,
2, 5, 8,
1, 6, 7};
double **A = ca_A_mR(a,i_mR(RA,CA));
double **B = ca_A_mR(b,i_mR(RA,Cb));
double **Inv = i_mR(RA,CA);
double **X = i_mR(RA,Cb);
double **T = i_mR(RA,Cb);
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(inv_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);
stop();
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 :
+4 +2 +3
+5 +3 +1
+8 +2 +2
b1 b2 ... bn :
+3 +4 +9
+2 +5 +8
+1 +6 +7
--------------------------------------
inv(A) :
-1.3333e-01 -6.6667e-02 +2.3333e-01
+6.6667e-02 +5.3333e-01 -3.6667e-01
+4.6667e-01 -2.6667e-01 -6.6667e-02
X = inv(A) * B :
x1 x2 ... xn
-0.3000 +0.5333 -0.1000
+0.9000 +0.7333 +2.3000
+0.8000 +0.1333 +1.6000
--------------------------------------
b1 b2 ... bn :
+3 +4 +9
+2 +5 +8
+1 +6 +7
Ax1 Ax2 ... Axn :
+3 +4 +9
+2 +5 +8
+1 +6 +7
Press return to continue.