Mathc matrices/c30d
Installer et compiler ces fichiers dans votre répertoire de travail.
c02a.c |
---|
/* ------------------------------------ */
/* Save as : c02a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R3*C6]={
-36, +21, -14, 1,0,0,
-38, +13, +27, 0,1,0,
+41, -6, -44, 0,0,1,
};
double inva[R3*C3]={
-410.00/7165.00, +1008.00/7165.00, +749.00/7165.00,
-565.00/7165.00, +2158.00/7165.00, +1504.00/7165.00,
-61.00/1433.00, +129.00/1433.00, +66.00/1433.00
};
double **A = ca_A_mR(a, i_mR(R3,C6));
double **invA = ca_A_mR(inva,i_mR(R3,C3));
double **T = i_mR(R3,C3);
int i = 1;
/* 1-----------------------------------
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
-38.00 +13.00 +27.00 +0.00 +1.00 +0.00
+41.00 -6.00 -44.00 +0.00 +0.00 +1.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R2 = -36*R2 \n"); mulR_mR(A,-36.,R2);
printf(" R3 = -36*R3 \n\n"); mulR_mR(A,-36.,R3);
printf(" R2 = 38*R1 + R2 \n");addR_mR(A, 38.,R1,R2);
printf(" R3 = -41*R1 + R3 \n");addR_mR(A,-41.,R1,R3);
p_mR(A,S11,P2,C6);
stop();
/* 2-----------------------------------
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +330.00 -1504.00 +38.00 -36.00 +0.00
+0.00 -645.00 +2158.00 -41.00 -0.00 -36.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R2 = 1./2.*R2 \n");mulR_mR(A, 1/2., R2);
p_mR(A,S11,P2,C6);
stop();
/* 3-----------------------------------
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 -645.00 +2158.00 -41.00 -0.00 -36.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R3 = 11.*R3 (165/645 = 11/43)\n"); mulR_mR(A,11.,R3);
printf(" R3 = 43.*R2 + R3 \n"); addR_mR(A,43.,R2,R3);
p_mR(A,S11,P2,C6);
stop();
/* 4-----------------------------------
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 +0.00 -8598.00 +366.00 -774.00 -396.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R3 = 1./6.*R3 \n");mulR_mR(A,1./6.,R3);
p_mR(A,S11,P2,C6);
stop();
/* 5-----------------------------------
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 +0.00 -1433.00 +61.00 -129.00 -66.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R1 = 1433.*R1 \n"); mulR_mR(A,1433.,R1);
printf(" R2 = 1433.*R2 \n"); mulR_mR(A,1433.,R2);
printf(" R3 = -1.*R3\n\n"); mulR_mR(A,-1.,R3);
printf(" R1 = 14.*R3 + R1\n");addR_mR(A,14.,R3,R1);
printf(" R2 = 752.*R3 + R2\n");addR_mR(A,752.,R3,R2);
p_mR(A,S11,P2,C6);
stop();
/* 6-----------------------------------
-51588.00 +30093.00 +0.00 +579.00 +1806.00 +924.00
+0.00 +236445.00 +0.00 -18645.00 +71214.00 +49632.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R2 = 1./33.*R2 \n");mulR_mR(A,1./33.,R2);
p_mR(A,S11,P2,C6);
stop();
/* 7-----------------------------------
-51588.000 +30093.000 +0.000 -15777.000
+0.000 +7165.000 +0.000 -81009.000
+0.000 +0.000 +1433.000 -5733.000
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R1 = -5.*R1 (30093/7165 = 21/5)\n");mulR_mR(A,-5.,R1);
printf(" R1 = 21.*R2 + R1 \n"); addR_mR(A,21.,R2,R1);
p_mR(A,S11,P2,C6);
stop();
/* 8-----------------------------------
+257940.00 +0.00 +0.00 -14760.00 +36288.00 +26964.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
------------------------------------ */
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R1 = 1./36.*R1 \n");mulR_mR(A,1./36.,R1);
p_mR(A,S11,P2,C6);
stop();
/* 9-----------------------------------
+7165.00 +0.00 +0.00 -410.00 +1008.00 +749.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
------------------------------------ */
clrscrn();
printf(" A : ");
ca_A_mR(a, A);
p_mR(A,S11,P2,C6);
printf(" A : inv_mR(invA, T); [see : double inva[R3*C3] ]");
inv_mR(invA, T);
p_mR(T, S11, P2, C6);
stop();
f_mR(A);
f_mR(invA);
f_mR(T);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Le but de ces exemples est d'inverser une matrice sans faire apparaître de fraction. La matrice double inva[R3*C3] donne le résultat calculé dans le fichier et permet de vérifier que inv(invA) = A.
Exemple de sortie écran :
------------------------------------
(1)
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
-38.00 +13.00 +27.00 +0.00 +1.00 +0.00
+41.00 -6.00 -44.00 +0.00 +0.00 +1.00
R2 = -36*R2
R3 = -36*R3
R2 = 38*R1 + R2
R3 = -41*R1 + R3
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +330.00 -1504.00 +38.00 -36.00 +0.00
+0.00 -645.00 +2158.00 -41.00 -0.00 -36.00
Press return to continue.
------------------------------------
(2)
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +330.00 -1504.00 +38.00 -36.00 +0.00
+0.00 -645.00 +2158.00 -41.00 -0.00 -36.00
R2 = 1./2.*R2
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 -645.00 +2158.00 -41.00 -0.00 -36.00
Press return to continue.
------------------------------------
(3)
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 -645.00 +2158.00 -41.00 -0.00 -36.00
R3 = 11.*R3 (165/645 = 11/43)
R3 = 43.*R2 + R3
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 +0.00 -8598.00 +366.00 -774.00 -396.00
Press return to continue.
------------------------------------
(4)
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 +0.00 -8598.00 +366.00 -774.00 -396.00
R3 = 1./6.*R3
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 +0.00 -1433.00 +61.00 -129.00 -66.00
Press return to continue.
------------------------------------
(5)
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
+0.00 +165.00 -752.00 +19.00 -18.00 +0.00
+0.00 +0.00 -1433.00 +61.00 -129.00 -66.00
R1 = 1433.*R1
R2 = 1433.*R2
R3 = -1.*R3
R1 = 14.*R3 + R1
R2 = 752.*R3 + R2
-51588.00 +30093.00 +0.00 +579.00 +1806.00 +924.00
+0.00 +236445.00 +0.00 -18645.00 +71214.00 +49632.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
Press return to continue.
------------------------------------
(6)
-51588.00 +30093.00 +0.00 +579.00 +1806.00 +924.00
+0.00 +236445.00 +0.00 -18645.00 +71214.00 +49632.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
R2 = 1./33.*R2
-51588.00 +30093.00 +0.00 +579.00 +1806.00 +924.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
Press return to continue.
------------------------------------
(7)
-51588.00 +30093.00 +0.00 +579.00 +1806.00 +924.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
R1 = -5.*R1 (30093/7165 = 21/5)
R1 = 21.*R2 + R1
+257940.00 +0.00 +0.00 -14760.00 +36288.00 +26964.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
Press return to continue.
------------------------------------
(8)
+257940.00 +0.00 +0.00 -14760.00 +36288.00 +26964.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
R1 = 1./36.*R1
+7165.00 +0.00 +0.00 -410.00 +1008.00 +749.00
+0.00 +7165.00 +0.00 -565.00 +2158.00 +1504.00
-0.00 -0.00 +1433.00 -61.00 +129.00 +66.00
Press return to continue.
------------------------------------
A :
-36.00 +21.00 -14.00 +1.00 +0.00 +0.00
-38.00 +13.00 +27.00 +0.00 +1.00 +0.00
+41.00 -6.00 -44.00 +0.00 +0.00 +1.00
A : inv_mR(invA, T); [see : double inva[R3*C3] ]
-36.00 +21.00 -14.00
-38.00 +13.00 +27.00
+41.00 -6.00 -44.00
Press return to continue.