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

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 : c00a.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ /* ------------------------------------ */ #define RA R3 #define CA C5 /* ------------------------------------ */ /* ------------------------------------ */ void fun(void) { double **A = r_mR( i_mR(RA,CA),9);/* RA,CA */ double **A_T = transpose_mR(A, i_mR(CA,RA)); /* CA,RA */ double **AA_T = mul_mR(A,A_T, i_mR(RA,RA)); /* RA,CA CA,RA */ double **invAA_T = inv_mR(AA_T, i_mR(RA,RA)); /* RA,RA */ double **A_TinvAA_T = mul_mR(A_T,invAA_T, i_mR(CA,RA)); /* CA,RA RA,RA */ double **Ide = mul_mR(A,A_TinvAA_T, i_mR(RA,RA)); /* RA,CA CA,RA */ clrscrn(); printf(" A :"); p_mR(A, S7,P2,C5); printf(" A_T :"); p_mR(A_T, S7,P1,C5); printf(" AA_T:"); p_mR(AA_T, S7,P1,C5); stop(); clrscrn(); printf(" inv(AA_T) :"); pE_mR(invAA_T, S12,P4,C5);; printf(" Pseudo Inverse = A_T inv(AA_T):"); pE_mR(A_TinvAA_T, S12,P4,C5); printf(" Ide = A (A_T inv(AA_T))"); p_mR(Ide, S7,P2,C5); f_mR(A); f_mR(A_T); f_mR(AA_T); f_mR(invAA_T); f_mR(A_TinvAA_T); f_mR(Ide); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A : -4.00 +9.00 -6.00 -1.00 -8.00 -8.00 -1.00 +8.00 -3.00 +2.00 -2.00 +2.00 -2.00 +3.00 +2.00 A_T : -4.0 -8.0 -2.0 +9.0 -1.0 +2.0 -6.0 +8.0 -2.0 -1.0 -3.0 +3.0 -8.0 +2.0 +2.0 AA_T: +198.0 -38.0 +19.0 -38.0 +142.0 -7.0 +19.0 -7.0 +25.0 Press return to continue. inv(AA_T) : +5.6840e-03 +1.3264e-03 -3.9484e-03 +1.3264e-03 +7.4504e-03 +1.0780e-03 -3.9484e-03 +1.0780e-03 +4.3303e-02 Pseudo Inverse = A_T inv(AA_T): -2.5450e-02 -6.7065e-02 -7.9436e-02 +4.1932e-02 +6.6435e-03 +4.9992e-02 -1.5596e-02 +4.9488e-02 -5.4291e-02 -2.1508e-02 -2.0443e-02 +1.3062e-01 -5.0716e-02 +6.4454e-03 +1.2035e-01 Ide = A (A_T inv(AA_T)) +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