Linear Algebra and the C Language/a03d
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R2*C3]={ 1,2,3,
4,5,6};
double b[R2*C3]={ 6,5,4,
3,2,1};
double **A = ca_A_mR(a,i_mR(R2,C3));
double **B = ca_A_mR(b,i_mR(R2,C3));
double **AplsB = i_mR(R2,C3);
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);
stop();
clrscrn();
printf(" Copy/Paste into the octave window.\n\n");
p_Octave_mR(A,"A", P0);
p_Octave_mR(B,"B", P0);
printf("A + B\n");
p_mR(AplsB,S4,P0,C6);
stop();
f_mR(A);
f_mR(B);
f_mR(AplsB);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
+1 +2 +3
+4 +5 +6
B :
+6 +5 +4
+3 +2 +1
A + B :
+7 +7 +7
+7 +7 +7
Press return to continue.
Copy/Paste into the octave window.
A=[
+1,+2,+3;
+4,+5,+6]
B=[
+6,+5,+4;
+3,+2,+1]
A + B
+7 +7 +7
+7 +7 +7
Press return to continue.