Mathc matrices/c083b
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
|---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define Cb C6
/* ------------------------------------ */
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(" \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");
stop();
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,C6);
printf(" b1 b2 ... bn :");
p_mR(B, S9,P0,C6);
stop();
clrscrn();
printf(" inv(A):");
pE_mR(InvA, S1,P4,C6);
printf(" X = inv(A) B :\n\n");
printf(" x1 x2 ... xn");
p_mR(X, S9,P4,C6);
stop();
clrscrn();
printf(" b1 b2 ... bn :");
p_mR(B, S9,P0,C6);
printf(" Ax1 Ax2 ... Axn :");
p_mR(mul_mR(A,X,B), S9,P0,C6);
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(RC5)+RC1);
} 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 :
+766 -263 -339 +266
+646 +266 +632 -533
+552 -339 +56 -645
+320 -447 -193 +380
b1 b2 ... bn :
+886 -287 +706 +804 +94 -263
-673 -829 -61 +112 +710 +32
+640 +202 -981 -907 -401 +660
-279 +364 +310 -595 +188 +580
inv(A) :
+1.0589e-03 +5.0817e-04 -1.1897e-04 -2.3039e-04
+1.4836e-03 +1.6291e-04 -8.9711e-04 -2.3327e-03
-1.7265e-03 +1.3907e-03 -5.3580e-04 +2.2497e-03
-2.3430e-05 +4.7002e-04 -1.2272e-03 +1.2242e-03
X = inv(A) * B :
x1 x2 ... xn
+0.5843 -0.8331 +0.7619 +1.1533 +0.4647 -0.4744
+1.2815 -1.5912 +1.1944 +3.4127 +0.1763 -2.3301
-3.4362 +0.0533 -0.0807 -2.0850 +1.4629 +1.4498
-1.4641 -0.1852 +1.5382 +0.4185 +1.0538 -0.0787
b1 b2 ... bn :
+886 -287 +706 +804 +94 -263
-673 -829 -61 +112 +710 +32
+640 +202 -981 -907 -401 +660
-279 +364 +310 -595 +188 +580
Ax1 Ax2 ... Axn :
+886 -287 +706 +804 +94 -263
-673 -829 -61 +112 +710 +32
+640 +202 -981 -907 -401 +660
-279 +364 +310 -595 +188 +580
Press return to continue
Press X to stop