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

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: c00i.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ /* ------------------------------------ */ double **X_sort_r_mR( double **Ab ) { double pivot; int c; int r; int r_pivot = R1; for ( c=C1; c<Ab[C_SIZE_A][C0]; c++) { r = r_pivot; pivot = 0.; while( (pivot<ERROR_E) && r<Ab[R_SIZE][C0] ) { pivot = fabs( Ab[r][c] ); clrscrn(); printf("/* --------- DEBUG 1 ---------- */\n\n"); printf(" AID: pivot[%d][%d] = %f ",r,c,pivot); p_mR(Ab, S8,P4,C8); if(pivot>ERROR_E) { swapR_mR(Ab, r, r_pivot); r_pivot++; } printf(" AID:"); p_mR(Ab, S8,P4,C8); stop(); clrscrn(); /* --------- DEBUG 1 ---------- */ r++; } } 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); sort_c_mR(AID); X_sort_r_mR(AID); printf("AID : After the function: sort_r_mR();"); p_mR(AID, S8,P4,C8); /* 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); 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"); 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 ---------- */ AID: pivot[1][1] = 0.000000 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 AID: +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: pivot[2][1] = 1.000000 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 AID: +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: pivot[2][2] = 1.000000 +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 AID: +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: pivot[3][3] = 1.000000 +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 AID: +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: pivot[4][4] = 1.000000 +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 AID: +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 Press return to continue. AID : After the function: sort_r_mR(); +1.0000 +0.0000 +0.0000 +0.0000 -3.2077 -4.9875 -10.8286 -3.3476 +0.0000 +1.0000 +0.0000 +0.0000 +4.1573 +6.2030 +12.2463 +3.0548 -0.0000 +0.0000 +1.0000 +0.0000 -2.5456 -2.6766 -4.9260 -2.5902 +0.0000 -0.0000 +0.0000 +1.0000 +1.2886 +4.3219 +7.5614 +1.0892 Copy/Paste into the octave window. format short e A=[ +0.6130,+0.9350,+0.0590,-0.5980; +0.7860,-0.2270,-0.9030,+0.9050; -0.4820,+0.0950,+0.6000,-0.3210; -0.4980,-0.8650,-0.6520,+0.2630] inv(A) Press return to continue Press X return to stop