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

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: c02a.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RA R3 #define CA C5 /* ------------------------------------ */ #define FACTOR_E +1.E-0 /* ------------------------------------ */ void fun(void) { double **A = r_mR( i_mR(RA,CA),9); double **Pinv = Pinv_Cn_mR(A, i_mR(CA,RA),FACTOR_E); double **Ide = mul_mR(A,Pinv, i_mR(RA,RA)); clrscrn(); printf(" A:"); p_mR(A, S7,P2,C7); printf(" PseudoInverse = V invS_T U_T "); pE_mR(Pinv, S12,P4,C10); printf(" Ide = A Pinv (The right inverse of A)"); p_mR(Ide, S7,P2,C10); f_mR(A); f_mR(Pinv); f_mR(Ide); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A : +6.00 -1.00 +1.00 -2.00 -9.00 -4.00 +5.00 +5.00 +2.00 -6.00 +4.00 -6.00 +3.00 +6.00 -6.00 PseudoInverse = V * invS_T * U_T +5.7066e-02 -5.2471e-02 +4.6021e-03 +1.8842e-02 +5.2565e-02 -6.2457e-02 -1.8199e-02 +4.7341e-02 +2.6768e-02 -7.1415e-02 +2.3166e-02 +8.2423e-02 -6.1313e-02 -4.0709e-02 -5.3345e-03 Ide = A * Pinv (The right inverse of A) +1.00 -0.00 -0.00 +0.00 +1.00 -0.00 +0.00 +0.00 +1.00 Press return to continue Press X return to stop