Linear Algebra and the C Language/a0ft
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define ARRAY A3
/* ------------------------------------ */
#define RA R5
#define CA C1
#define CB C3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A[ARRAY];
double **B = i_mR(RA,CB);
int i;
for(i=A0; i<ARRAY; i++)
A[i] = r_mR(i_mR(RA,CA),99);
clrscrn();
add_mR(A[A0],A[A1],A[A2]);
for(i=A0; i<ARRAY; i++)
c_c_mR(A[i],C1, B,i+C1);
printf(" Add two vectors:\n\n");
printf(" A[0] + A[1] = A[2] :");
p_mR(B, S8,P0,C10);
for(i=A0; i<ARRAY; i++)
f_mR(A[i]);
f_mR(B);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Add two vectors:
Screen output example:
Add two vectors:
A[0] + A[1] = A[2] :
+60 +9 +69
-23 -65 -88
-16 -6 -22
+22 -40 -18
+97 -55 +42
Press return to continue
Press X return to stop