Linear Algebra and the C Language/a0hu
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A = rupper_mR(i_mR(rc,rc),9);
double **B = rupper_mR(i_mR(rc,rc),9);
double **AB = i_mR(rc,rc);
clrscrn();
printf(" A:");
p_mR(A ,S4,P0,C6);
printf(" B:");
p_mR(B ,S4,P0,C6);
printf(" AB:");
p_mR(mul_mR(A,B,AB) ,S4,P0,C6);
f_mR(A);
f_mR(B);
f_mR(AB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(rp_I(RC3)+RC1);
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Multiplying upper triangular matrices
Screen output example:
A:
+2 -4 +2 +2
+0 +5 +3 -2
+0 +0 -6 +5
+0 +0 +0 +2
B:
-6 +6 -1 -8
+0 +1 +8 -8
+0 +0 -8 +5
+0 +0 +0 +7
AB:
-12 +8 -50 +40
+0 +5 +16 -39
+0 +0 +48 +5
+0 +0 +0 +14
Press return to continue
Press X return to stop