Linear Algebra and the C Language/a03m
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c01b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R3
#define CA C2
/* ------------------------------------ */
#define FACTOR_E +1.E-0
/* ------------------------------------ */
int main(void)
{
double tA[RA*CA]={
1, -1,
3, 2,
-2, 4
};
double **A = ca_A_mR(tA, i_mR(RA,CA));
double **Pinv = Pinv_Rn_mR(A, i_mR(CA,RA),FACTOR_E);;
double **Ide = mul_mR(Pinv,A, i_mR(CA,CA)); ;
clrscrn();
printf(" A:");
p_mR(A, S7,P2,C7);
printf(" Pinv = V invS_T U_T ");
pE_mR(Pinv, S12,P4,C10);
printf(" Ide = Pinv A (The left inverse of A)");
p_mR(Ide, S7,P2,C10);
stop();
f_mR(A);
f_mR(Pinv);
f_mR(Ide);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
+1.00 -1.00
+3.00 +2.00
-2.00 +4.00
Pinv = V * invS_T * U_T
+6.3158e-02 +2.4211e-01 -1.0526e-01
-3.8596e-02 +1.2982e-01 +1.7544e-01
Ide = Pinv * A (The left inverse of A)
+1.00 +0.00
-0.00 +1.00
Press return to continue.