Linear Algebra and the C Language/a0fn
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define ARRAY A3
/* ------------------------------------ */
void fun(int r,int c)
{
double **A[ARRAY];
A[A0] = i_mR(r,c);
A[A1] = i_mR(r,c);
A[A2] = i_mR(r,c);
r_mR(A[A0],9);
r_mR(A[A1],9);
clrscrn();
printf(" A[0]: ");
p_mR(A[A0], S5,P0,C6);
printf(" A[1]: ");
p_mR(A[A1], S5,P0,C6);
add_mR(A[A0],A[A1],A[A2]);
printf(" A[2] = A[0] + A[A1]: ");
p_mR(A[A2], S5,P0,C6);
f_mR(A[A0]);
f_mR(A[A1]);
f_mR(A[A2]);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do{
fun(rp_I(R5),rp_I(C5));
}while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Create and initialize an array of matrices:
Screen output example:
A[0]:
+2 +4 -5
+8 -2 +7
-3 +6 +4
-8 -1 -7
-6 -5 -9
A[1]:
-8 -6 -2
+6 +4 -8
-6 -3 -1
+3 +6 +2
-6 -4 -2
A[2] = A[0] + A[A1]:
-6 -2 -7
+14 +2 -1
-9 +3 +3
-5 +5 -5
-12 -9 -11
Press return to continue
Press X return to stop