Linear Algebra and the C Language/a072
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R3
#define CA C3
#define Cb C3
/* ------------------------------------ */
int main(void)
{
double at[RA*CA]={
+10, -150, -148,
+207, -215, +997,
-858, +803, +289
};
double bt[RA*Cb]={
+437, -146, -175,
-233, +243, +772,
+444, -886, -604,
};
double **A = ca_A_mR(at, i_mR(RA,CA));
double **b = ca_A_mR(bt, i_mR(RA,Cb));
double **Ab = c_A_b_Ab_mR(A,b, i_Abr_Ac_bc_mR(RA,CA,Cb));
clrscrn();
printf(" A:");
p_mR(A, S8,P0,C3);
printf(" b1 b2 b3:");
p_mR(b, S8,P0,C3);
stop();
clrscrn();
printf(" Copy/Paste into the octave window.\n\n");
p_Octave_mR(Ab,"Ab",P0);
printf("\n rref(Ab,.00000000001)\n\n");
printf(" gj_TP_mR(Ab):");
p_mR(gj_TP_mR(Ab), S10,P4,C3);
stop();
f_mR(Ab);
f_mR(b);
f_mR(A);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A:
+10 -150 -148
+207 -215 +997
-858 +803 +289
b1 b2 b3:
+437 -146 -175
-233 +243 +772
+444 -886 -604
Press return to continue.
Copy/Paste into the octave window.
Ab=[
+10,-150,-148,+437,-146,-175;
+207,-215,+997,-233,+243,+772;
-858,+803,+289,+444,-886,-604]
rref(Ab,.00000000001)
gj_TP_mR(Ab):
+1.0000 +0.0000 -0.0000
-0.0000 +1.0000 -0.0000
+0.0000 +0.0000 +1.0000
-3.3492 +2.0425 +1.5396
-2.9619 +1.0616 +0.6767
-0.1771 +0.0486 +0.6006
Press return to continue.