Mathc matrices/c30h
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c02.c |
---|
/* ------------------------------------ */
/* Save as : c02.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R3*C6]={
-56, +21, 1,0,
-38, +43, 0,1,
};
double inva[R2*C2]={
-43.00/1610.00, +21.00/1610.00,
-19.00/ 805.00, +28.00/ 805.00,
};
double **A = ca_A_mR(a, i_mR(R2,C4));
double **invA = ca_A_mR(inva,i_mR(R2,C2));
double **T = i_mR(R2,C2);
int i = 1;
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R2 = -56*R2 \n"); mulR_mR(A,-56.,R2);
printf(" R2 = +38*R1 + R2 \n");addR_mR(A,+38.,R1,R2);
p_mR(A,S11,P2,C6);
stop();
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();
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R1 = +805*R1 \n"); mulR_mR(A,+805.,R1);
printf(" R1 = -21*R2 + R1 \n");addR_mR(A,-21.,R2,R1);
p_mR(A,S11,P2,C6);
stop();
clrscrn();
printf(" (%d) \n\n",i++);
p_mR(A,S11,P2,C6);
printf(" R1 = -1/28*R1 \n"); mulR_mR(A,-1/28.,R1);
p_mR(A,S11,P2,C6);
stop();
clrscrn();
printf(" A : ");
ca_A_mR(a, A);
p_mR(A,S11,P2,C6);
printf(" double inva[R2*C2]={\n"
" -43.00/1610.00, +21.00/1610.00,\n"
" -19.00/ 805.00, +28.00/ 805.00, };\n\n"
" double **invA = ca_A_mR(inva,i_mR(R2,C2));\n\n" );
printf(" A : inv_mR(invA, T);");
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)
-56.00 +21.00 +1.00 +0.00
-38.00 +43.00 +0.00 +1.00
R2 = -56*R2
R2 = +38*R1 + R2
-56.00 +21.00 +1.00 +0.00
+0.00 -1610.00 +38.00 -56.00
Press return to continue.
------------------------------------
(2)
-56.00 +21.00 +1.00 +0.00
+0.00 -1610.00 +38.00 -56.00
R2 = -1/2*R2
-56.00 +21.00 +1.00 +0.00
-0.00 +805.00 -19.00 +28.00
Press return to continue.
------------------------------------
(3)
-56.00 +21.00 +1.00 +0.00
-0.00 +805.00 -19.00 +28.00
R1 = +805*R1
R1 = -21*R2 + R1
-45080.00 +0.00 +1204.00 -588.00
-0.00 +805.00 -19.00 +28.00
Press return to continue.
------------------------------------
(4)
-45080.00 +0.00 +1204.00 -588.00
-0.00 +805.00 -19.00 +28.00
R1 = -1/28*R1
+1610.00 -0.00 -43.00 +21.00
-0.00 +805.00 -19.00 +28.00
Press return to continue.
------------------------------------
A :
-56.00 +21.00 +1.00 +0.00
-38.00 +43.00 +0.00 +1.00
double inva[R2*C2]={
-43.00/1610.00, +21.00/1610.00,
-19.00/ 805.00, +28.00/ 805.00, };
double **invA = ca_A_mR(inva,i_mR(R2,C2));
A : inv_mR(invA, T);
-56.00 +21.00
-38.00 +43.00
Press return to continue.