Linear Algebra and the C Language/a0go
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A = rsymmetric_mR(i_mR(rc,rc),9);
double **B = rsymmetric_mR(i_mR(rc,rc),9);
double **AplsB = i_mR(rc,rc);
clrscrn();
printf(" A:");
p_mR(A, S4,P0,C6);
printf(" B:");
p_mR(B, S4,P0,C6);
printf(" A + B:");
p_mR(add_mR(A,B,AplsB), S4,P0,C6);
f_mR(A);
f_mR(B);
f_mR(AplsB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(rp_I(RC3)+RC1);
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The sum of two symmetric matrices is symmetric.
Screen output example:
A:
-4 +9 +4 -6
+9 +6 -6 -1
+4 -6 +8 +8
-6 -1 +8 +6
B:
+7 -6 +6 -9
-6 -8 -1 +7
+6 -1 -4 +6
-9 +7 +6 +6
A + B:
+3 +3 +10 -15
+3 -2 -7 +6
+10 -7 +4 +14
-15 +6 +14 +12
Press return to continue
Press X return to stop