Linear Algebra and the C Language/a06z
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define Cb C1
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR( i_mR(r,r),999);
double **b = r_mR( i_mR(r,Cb),999);
double **Ab = c_A_b_Ab_mR(A,b, /* Copy A and b onto Ab */
i_Abr_Ac_bc_mR(r,r,Cb)); /* Create the matrix Ab */
clrscrn();
printf(" A:");
p_mR(A, S8,P0,C7);
printf(" b:");
p_mR(b, S8,P0,C7);
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,C7);
f_mR(Ab);
f_mR(b);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC5)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
-293 +33 +743 +429
+401 -332 +814 +218
+258 +324 +305 -764
-873 +764 -108 -200
b :
-931
+201
-479
-799
Press return to continue.
Copy/Paste into the octave window.
Ab=[
-293,+33,+743,+429,-931;
+401,-332,+814,+218,+201;
+258,+324,+305,-764,-479;
-873,+764,-108,-200,-799]
rref(Ab,.00000000001)
gj_TP_mR(Ab) :
+1.0000 +0.0000 +0.0000 +0.0000 +45.7387
+0.0000 +1.0000 +0.0000 +0.0000 +60.1249
+0.0000 +0.0000 +1.0000 +0.0000 -8.0366
+0.0000 +0.0000 +0.0000 +1.0000 +38.3624
Press return to continue
Press X return to stop