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/a03p

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. /* ------------------------------------ */ /* Save as: c01e.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RA R5 #define CA C3 /* ------------------------------------ */ #define FACTOR_E +1.E-0 /* ------------------------------------ */ void fun(void) { double **A = r_mR( i_mR(RA,CA),9); double **Pinv = Pinv_Rn_mR(A, i_mR(CA,RA),FACTOR_E); double **PinvA = mul_mR(Pinv,A, i_mR(CA,CA)); double **PinvAPinv = mul_mR(PinvA,Pinv, i_mR(CA,RA)); clrscrn(); printf(" A:"); p_mR(A, S7,P2,C7); printf(" Pinv = V invS_T U_T "); pE_mR(Pinv, S12,P4,C10); stop(); clrscrn(); printf(" Pinv*A:"); p_mR(PinvA, S7,P2,C10); printf(" Pinv*A*Pinv:"); p_mR(PinvAPinv, S7,P4,C10); printf(" Pinv:"); p_mR(Pinv, S7,P4,C7); f_mR(A); f_mR(Pinv); f_mR(PinvA); f_mR(PinvAPinv); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A : +2.00 -3.00 -8.00 +6.00 -1.00 -2.00 +3.00 -7.00 +5.00 +3.00 +2.00 +1.00 +6.00 -4.00 -1.00 Pinv = V * invS_T * U_T -2.5492e-02 +8.6143e-02 -1.0818e-02 +7.7915e-02 +5.5473e-02 -5.7862e-02 +4.2756e-02 -9.3775e-02 +7.6606e-02 -1.4884e-02 -9.0331e-02 -5.1942e-03 +4.7848e-02 +2.6068e-02 -1.6535e-03 Press return to continue. Pinv*A : +1.00 +0.00 -0.00 -0.00 +1.00 +0.00 +0.00 -0.00 +1.00 Pinv*A*Pinv : -0.0255 +0.0861 -0.0108 +0.0779 +0.0555 -0.0579 +0.0428 -0.0938 +0.0766 -0.0149 -0.0903 -0.0052 +0.0478 +0.0261 -0.0017 Pinv : -0.0255 +0.0861 -0.0108 +0.0779 +0.0555 -0.0579 +0.0428 -0.0938 +0.0766 -0.0149 -0.0903 -0.0052 +0.0478 +0.0261 -0.0017 Press return to continue Press X return to stop