Linear Algebra and the C Language/a03h
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00e.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R3*C2]={ 1,2,
4,5,
7,8};
double **A = ca_A_mR(a,i_mR(R3,C2));
double **sA = i_mR(R3,C2);
double s = r_I(9);
clrscrn();
printf("\n s = %+.2f \n\n",s);
printf(" A : ");
p_mR(r_mR(A,9),S6,P0,C6);
printf(" sA : ");
p_mR(smul_mR(s,A,sA),S6,P0,C6);
stop();
clrscrn();
printf(" Copy/Paste into the octave window.\n\n");
p_Octave_mR(A,"A", P0);
printf("%.0f*A\n",s);
p_mR(sA,S6,P0,C6);
stop();
f_mR(A);
f_mR(sA);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
s = +2.00
A :
-1 -6
+2 -7
-6 -6
sA :
-2 -12
+4 -14
-12 -12
Press return to continue.
Copy/Paste into the octave window.
A=[
-1,-6;
+2,-7;
-6,-6]
2*A
-2 -12
+4 -14
-12 -12
Press return to continue.