Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Linear Algebra and the C Language/a04j

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install and compile this file in your working directory. thumb| /* ------------------------------------ */ /* Save as: c00c.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ /* ------------------------------------ */ #define RA R5 #define CA C4 #define Cb C1 /* ------------------------------------ */ #define FACTOR_E +1.E-0 /* ------------------------------------ */ int main(void) { double ta[RA*(CA+Cb)]={ /* x2 x4 x6 x7 */ -1, +0, +0, +0, +1, +1, +0, +0, +0, +0, +1, -1, +0, +0, +0, +1, +0, -1, -1, +0, }; double tb[RA*(CA+Cb)]={ +20 -50, +60, -60, +90 -20, +50 -90 }; double **A = ca_A_mR(ta, i_mR(RA,CA)); double **b = ca_A_mR(tb, i_mR(RA,C1)); double **Pinv = Pinv_Rn_mR(A, i_mR(CA,RA),FACTOR_E); double **x = mul_mR(Pinv,b, 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 "); pE_mR(Pinv, S12,P4,C6); printf(" x = Pinv b "); p_mR(x, S10,P4,C6); stop(); f_mR(b); f_mR(A); f_mR(Pinv); f_mR(x); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb| Screen output example: A : -1.0 +0.0 +0.0 +0.0 +1.0 +1.0 +0.0 +0.0 +0.0 +0.0 +1.0 -1.0 +0.0 +0.0 +0.0 +1.0 +0.0 -1.0 -1.0 +0.0 b : -30.0 +60.0 -60.0 +70.0 -40.0 Press return to continue. Pinv = V * invS_T * U_T -8.0000e-01 +2.0000e-01 +2.0000e-01 +2.0000e-01 +2.0000e-01 +6.0000e-01 +6.0000e-01 -4.0000e-01 -4.0000e-01 -4.0000e-01 -4.0000e-01 -4.0000e-01 +6.0000e-01 +6.0000e-01 -4.0000e-01 -2.0000e-01 -2.0000e-01 -2.0000e-01 +8.0000e-01 -2.0000e-01 x = Pinv * b +30.0000 +30.0000 +10.0000 +70.0000 Press return to continue.