Linear Algebra and the C Language/a04o
Install and compile this file in your working directory.

/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define RA R8
#define CA C6
#define Cb C1
/* ------------------------------------ */
#define FACTOR_E +1.E-1
/* ------------------------------------ */
int main(void)
{
double ta[RA*(CA+Cb)]={
// I1 I2 I3 I4 I5 I6
+1, -1, -1, +0, +0, +0,
+0, +0, +1, -1, -1, +0,
+0, +1, +0, +0, +1, -1,
-1, +0, +0, +1, +0, +1,
+0, -50, +0, +0, +0, -20,
+0, +50, -20, +0, -10, +0,
+0, +0, +0, -50, +10, +20,
+0, +0, -20, -50, +0, +0,
};
double tb[RA*(CA+Cb)]={
0,
0,
0,
0,
-90,
0,
0,
-90,
};
double **A = ca_A_mR(ta,i_mR(RA,CA));
double **b = ca_A_mR(tb,i_mR(RA,C1));
double **Pinv = i_mR(CA,RA);
double **x = i_mR(CA,C1);
clrscrn();
printf(" A :");
p_mR(A,S5,P1,C6);
printf(" b :");
p_mR(b,S5,P1,C6);
stop();
clrscrn();
printf(" Pinv = V * invS_T * U_T ");
Pinv_Rn_mR(A,Pinv,FACTOR_E);
pE_mR(Pinv,S12,P3,C5);
printf(" x = Pinv * b ");
mul_mR(Pinv,b,x);
p_mR(x,S10,P3,C5);
stop();
f_mR(b);
f_mR(A);
f_mR(Pinv);
f_mR(x);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:
A :
+1.0 -1.0 -1.0 +0.0 +0.0 +0.0
+0.0 +0.0 +1.0 -1.0 -1.0 +0.0
+0.0 +1.0 +0.0 +0.0 +1.0 -1.0
-1.0 +0.0 +0.0 +1.0 +0.0 +1.0
+0.0 -50.0 +0.0 +0.0 +0.0 -20.0
+0.0 +50.0 -20.0 +0.0 -10.0 +0.0
+0.0 +0.0 +0.0 -50.0 +10.0 +20.0
+0.0 +0.0 -20.0 -50.0 +0.0 +0.0
b :
+0.0
+0.0
+0.0
+0.0
-90.0
+0.0
+0.0
-90.0
Press return to continue.
Pinv = V * invS_T * U_T
+5.000e-01 +5.556e-02 -5.556e-02 -5.000e-01 -1.667e-02
-7.143e-02 +3.439e-02 +1.085e-01 -7.143e-02 -9.127e-03
-1.786e-01 +2.712e-01 +8.598e-02 -1.786e-01 -7.540e-03
+7.143e-02 -1.085e-01 -3.439e-02 +7.143e-02 -1.984e-03
+5.755e-11 -3.704e-01 +3.704e-01 +6.044e-11 -5.556e-03
+1.786e-01 -8.598e-02 -2.712e-01 +1.786e-01 -1.468e-02
-5.556e-03 +5.556e-03 -1.667e-02
+7.275e-03 -1.323e-04 -1.984e-03
-1.283e-02 +5.688e-03 -1.468e-02
+1.323e-04 -7.275e-03 -9.127e-03
-1.296e-02 +1.296e-02 -5.556e-03
-5.688e-03 +1.283e-02 -7.540e-03
x = Pinv * b
+3.000
+1.000
+2.000
+1.000
+1.000
+2.000
Press return to continue.