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

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: c00b.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ /* ------------------------------------ */ double **X_invgj_mR( double **A, double **invA ) { double **ID = i_RC_mR(A[R_SIZE][C0],A[C_SIZE][C0]); double **AID; int r = A[R_SIZE][C0]; r--; AID = i_Abr_Ac_bc_mR(r,r,r); clrscrn(); printf("/* --------- DEBUG 1 ---------- */\n"); printf(" A:"); p_mR(A, S3,P3,C8); printf(" ID:"); p_mR(eye_mR(ID), S3,P3,C8); printf(" AID:"); p_mR(AID, S3,P3,C8); printf("/* --------- DEBUG 2 ---------- */\n"); c_A_b_Ab_mR(A,ID,AID); /* --------------------------- */ printf(" AID: c_A_b_Ab_mR(A,ID,AID);"); p_mR(AID, S3,P3,C8); stop(); clrscrn(); printf("/* --------- DEBUG 3 ---------- */\n"); invgj_pivot_mR(AID); /* --------------------------- */ printf(" AID: invgj_pivot_mR(AID);"); p_mR(AID, S6,P2,C8); printf("/* --------- DEBUG 4 ---------- */\n"); printf(" AID:\n"); pall_mR(AID, S6,P2,C8); sort_c_mR(AID); /* --------------------------- */ printf(" AID: sort_c_mR(AID);\n"); pall_mR(AID, S6,P2,C8); stop(); clrscrn(); printf("/* --------- DEBUG 5 ---------- */\n"); printf(" AID:"); p_mR(AID, S6,P2,C8); sort_r_mR(AID); /* --------------------------- */ printf(" AID: sort_r_mR(AID);"); p_mR(AID, S6,P2,C8); printf("/* --------- DEBUG 6 ---------- */\n"); c_Inv_A_mR(AID,invA); /* --------------------------- */ printf(" invA: c_Inv_A_mR(AID,invA);"); p_mR(invA, S6,P2,C8); stop(); clrscrn(); f_mR(AID); f_mR(ID); return(invA); } /* ------------------------------------ */ /* ------------------------------------ */ void fun(int r) { double **A = rE_mR( i_mR(r,r), 999.,1E-3); double **InvA = i_mR(r,r); X_invgj_mR(A,InvA); printf(" Copy/Paste into the octave window.\n\n"); printf("format short e\n"); p_Octave_mR(A,"A",P4); printf(" inv(A)\n\n"); printf(" invA:"); pE_mR(InvA, S12,P4,C8); f_mR(InvA); f_mR(A); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(C3); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: /* --------- DEBUG 3 ---------- */ AID: invgj_pivot_mR(AID); +1.00 +0.00 +0.00 -0.51 -0.52 +0.68 -0.00 +1.00 +0.00 -0.96 -2.32 -1.94 -0.00 -0.00 +1.00 -3.84 -2.75 -2.01 /* --------- DEBUG 4 ---------- */ AID: +4 +2 +1 +3 +5 +4 +6 +7 +1.00 +0.00 +0.00 -0.51 -0.52 +0.68 +4 -0.00 +1.00 +0.00 -0.96 -2.32 -1.94 +0 -0.00 -0.00 +1.00 -3.84 -2.75 -2.01 AID: sort_c_mR(AID); +4 +1 +2 +3 +4 +5 +6 +7 +0.00 +1.00 +0.00 -0.52 -0.51 +0.68 +4 +1.00 -0.00 +0.00 -2.32 -0.96 -1.94 +0 -0.00 -0.00 +1.00 -2.75 -3.84 -2.01 Press return to continue. /* --------- DEBUG 5 ---------- */ AID: +0.00 +1.00 +0.00 -0.52 -0.51 +0.68 +1.00 -0.00 +0.00 -2.32 -0.96 -1.94 -0.00 -0.00 +1.00 -2.75 -3.84 -2.01 AID: sort_r_mR(AID); +1.00 -0.00 +0.00 -2.32 -0.96 -1.94 +0.00 +1.00 +0.00 -0.52 -0.51 +0.68 -0.00 -0.00 +1.00 -2.75 -3.84 -2.01 /* --------- DEBUG 6 ---------- */ invA: c_Inv_A_mR(AID,invA); -2.32 -0.96 -1.94 -0.52 -0.51 +0.68 -2.75 -3.84 -2.01 Press return to continue. Copy/Paste into the octave window. format short e A=[ -0.5360,-0.8130,+0.2430; +0.4300,+0.1020,-0.3820; -0.0880,+0.9190,-0.1010] inv(A) invA: -2.3169e+00 -9.6007e-01 -1.9431e+00 -5.2385e-01 -5.1348e-01 +6.8170e-01 -2.7479e+00 -3.8356e+00 -2.0052e+00 Press return to continue Press X return to stop