Linear Algebra and the C Language/a0gd
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void AplsB(int r)
{
double **A = i_mR(r,r);
double **B = i_mR(r,r);
double **C = i_mR(r,r);
double **D = i_mR(r,r);
double **T = i_mR(r,r);
double **AB = i_mR(r,r);
double **BA = i_mR(r,r);
r_commute4_mR(A,B,C,D,9);
clrscrn();
printf(" A:");
p_mR(A, S5,P3,C6);
printf(" B:");
p_mR(B, S5,P3,C6);
printf(" C:");
p_mR(C, S5,P3,C6);
printf(" D:");
p_mR(D, S5,P3,C6);
stop();
clrscrn();
printf(" AB:");
p_mR(mul_mR(A,B,AB), S5,P9,C6);
printf(" BA:");
p_mR(mul_mR(B,A,BA), S5,P9,C6);
stop();
clrscrn();
printf(" AC:");
p_mR(mul_mR(A,C,AB), S5,P9,C6);
printf(" CA:");
p_mR(mul_mR(C,A,BA), S5,P9,C6);
stop();
clrscrn();
printf(" BC:");
p_mR(mul_mR(B,C,AB), S5,P9,C6);
printf(" CB:");
p_mR(mul_mR(C,B,BA), S5,P9,C6);
stop();
clrscrn();
printf(" AD:");
p_mR(mul_mR(A,D,AB), S5,P9,C6);
printf(" DA:");
p_mR(mul_mR(D,A,BA), S5,P9,C6);
stop();
clrscrn();
printf(" BD:");
p_mR(mul_mR(B,D,AB), S5,P9,C6);
printf(" DB:");
p_mR(mul_mR(D,B,BA), S5,P9,C6);
stop();
clrscrn();
printf(" CD:");
p_mR(mul_mR(C,D,AB), S5,P9,C6);
printf(" DC:");
p_mR(mul_mR(D,C,BA), S5,P9,C6);
f_mR(A);
f_mR(B);
f_mR(C);
f_mR(D);
f_mR(T);
f_mR(AB);
f_mR(BA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
AplsB(RC3);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Four commutative matrices:
Screen output example:
A:
-0.455 -0.154 +0.004
-0.050 -0.619 -0.001
+0.227 -0.173 -0.652
B:
-0.616 +1.046 -0.029
+0.343 +0.492 +0.007
-1.542 +1.177 +0.721
C:
-0.005 -0.010 +0.000
-0.003 -0.016 -0.000
+0.015 -0.011 -0.018
D:
+0.005 +0.010 -0.000
+0.003 +0.016 +0.000
-0.015 +0.011 +0.018
Press return to continue.
AB:
+0.221370207 -0.547138127 +0.015412342
-0.179168471 -0.358519146 -0.003853085
+0.806258121 -0.615530393 -0.477964794
BA:
+0.221370207 -0.547138127 +0.015412342
-0.179168471 -0.358519146 -0.003853085
+0.806258121 -0.615530393 -0.477964794
Press return to continue.
AC:
+0.002957845 +0.006889328 -0.000194066
+0.002256012 +0.010259563 +0.000048516
-0.010152056 +0.007750494 +0.011763571
CA:
+0.002957845 +0.006889328 -0.000194066
+0.002256012 +0.010259563 +0.000048516
-0.010152056 +0.007750494 +0.011763571
Press return to continue.
BC:
-0.000582702 -0.010052002 +0.000283155
-0.003291677 -0.011236408 -0.000070789
+0.014812545 -0.011308502 -0.013430859
CB:
-0.000582702 -0.010052002 +0.000283155
-0.003291677 -0.011236408 -0.000070789
+0.014812545 -0.011308502 -0.013430859
Press return to continue.
AD:
-0.002957842 -0.006889316 +0.000194065
-0.002256008 -0.010259546 -0.000048516
+0.010152037 -0.007750480 -0.011763551
DA:
-0.002957842 -0.006889316 +0.000194065
-0.002256008 -0.010259546 -0.000048516
+0.010152037 -0.007750480 -0.011763551
Press return to continue.
BD:
+0.000582698 +0.010051988 -0.000283155
+0.003291672 +0.011236389 +0.000070789
-0.014812524 +0.011308486 +0.013430837
DB:
+0.000582698 +0.010051988 -0.000283155
+0.003291672 +0.011236389 +0.000070789
-0.014812524 +0.011308486 +0.013430837
Press return to continue.
CD:
-0.000063883 -0.000205158 +0.000005779
-0.000067182 -0.000281322 -0.000001445
+0.000302319 -0.000230803 -0.000326110
DC:
-0.000063883 -0.000205158 +0.000005779
-0.000067182 -0.000281322 -0.000001445
+0.000302319 -0.000230803 -0.000326110
Press return to continue
Press X return to stop