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

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: c00g.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ /* ------------------------------------ */ double **X_sort_c_mR( double **Ab ) { double **T = i_RC_mR(Ab[R_SIZE][C0],Ab[C_SIZE][C0]); int c; for(c=C1; c<Ab[C_SIZE][C0]; c++) { clrscrn(); printf("/* --------- DEBUG 1 ---------- */ \n\n"); printf(" Copy C[%d] of AID into C[%.0f] of T\n",c,Ab[R0][c]); pall_mR(Ab, S7,P3,C9); c_c_withR0_mR( Ab, c, T, Ab[R0][c]); printf(" T[R0][%.0f]\n",Ab[R0][c]); pall_mR(T, S7,P3,C9); stop(); clrscrn(); /* --------- DEBUG 1 ---------- */ } printf(" AID : before sort_c_mR();\n"); pall_mR(Ab, S7,P3,C9); c_withR0_mR(T,Ab); printf(" The rows are not sorted:\n\n" " AID : after sort_c_mR();\n"); pall_mR(Ab, S7,P3,C9); f_mR(T); return(Ab); } /* ------------------------------------ */ /* ------------------------------------ */ 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); eye_mR(ID); c_A_b_Ab_mR(A,ID,AID); invgj_pivot_mR(AID); X_sort_c_mR(AID); /* sort_r_mR(AID); */ /* c_Inv_A_mR(AID,invA); */ 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); clrscrn(); X_invgj_mR(A,InvA); f_mR(InvA); f_mR(A); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(C4); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: /* --------- DEBUG 1 ---------- */ Copy C[1] of AID into C[3] of T +5 +3 +4 +1 +2 +7 +8 +5 +6 +9 +1.000 +0.000 +0.000 +0.000 +0.523 -2.500 +1.598 -1.256 +5 +0.000 +1.000 +0.000 +0.000 +0.961 +0.109 -0.470 -0.133 +0 +0.000 +0.000 +1.000 +0.000 +0.431 +3.321 -1.079 +2.115 +0 +0.000 +0.000 +0.000 +1.000 +0.694 +3.979 -1.906 +0.313 T[R0][3] +5 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 Press return to continue. /* --------- DEBUG 1 ---------- */ Copy C[2] of AID into C[4] of T +5 +3 +4 +1 +2 +7 +8 +5 +6 +9 +1.000 +0.000 +0.000 +0.000 +0.523 -2.500 +1.598 -1.256 +5 +0.000 +1.000 +0.000 +0.000 +0.961 +0.109 -0.470 -0.133 +0 +0.000 +0.000 +1.000 +0.000 +0.431 +3.321 -1.079 +2.115 +0 +0.000 +0.000 +0.000 +1.000 +0.694 +3.979 -1.906 +0.313 T[R0][4] +5 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 Press return to continue. /* --------- DEBUG 1 ---------- */ Copy C[3] of AID into C[1] of T +5 +3 +4 +1 +2 +7 +8 +5 +6 +9 +1.000 +0.000 +0.000 +0.000 +0.523 -2.500 +1.598 -1.256 +5 +0.000 +1.000 +0.000 +0.000 +0.961 +0.109 -0.470 -0.133 +0 +0.000 +0.000 +1.000 +0.000 +0.431 +3.321 -1.079 +2.115 +0 +0.000 +0.000 +0.000 +1.000 +0.694 +3.979 -1.906 +0.313 T[R0][1] +5 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0 +1.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 Press return to continue. *** **** *** AID : before sort_c_mR(); +5 +3 +4 +1 +2 +7 +8 +5 +6 +9 +1.000 +0.000 +0.000 +0.000 +0.523 -2.500 +1.598 -1.256 +5 +0.000 +1.000 +0.000 +0.000 +0.961 +0.109 -0.470 -0.133 +0 +0.000 +0.000 +1.000 +0.000 +0.431 +3.321 -1.079 +2.115 +0 +0.000 +0.000 +0.000 +1.000 +0.694 +3.979 -1.906 +0.313 The rows are not sorted: AID : after sort_c_mR(); +5 +1 +2 +3 +4 +5 +6 +7 +8 +9 +0.000 +0.000 +1.000 +0.000 +1.598 -1.256 +0.523 -2.500 +5 +0.000 +0.000 +0.000 +1.000 -0.470 -0.133 +0.961 +0.109 +0 +1.000 +0.000 +0.000 +0.000 -1.079 +2.115 +0.431 +3.321 +0 +0.000 +1.000 +0.000 +0.000 -1.906 +0.313 +0.694 +3.979 Press return to continue Press X return to stop