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

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: c00h.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++) /* From the first row */ { /* to the last */ r = r_pivot; pivot = 0.; while( (pivot<ERROR_E) && r<Ab[R_SIZE][C0] ) { pivot = fabs( Ab[r][c] ); if(pivot>ERROR_E) /* If the pivot is not zero */ { /* swap the row */ swapR_mR(Ab, r, r_pivot); r_pivot++; } 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); printf(" AID: Before sort_r_mR();"); p_mR(AID, S8,P4,C9); X_sort_r_mR(AID); printf(" See above for the function code: sort_r_mR(); \n\n" " AID: After sort_r_mR();"); p_mR(AID, S8,P4,C9); /* 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: AID: Before sort_r_mR(); +0.0000 +0.0000 +0.0000 +1.0000 +0.2946 +1.2943 +1.3303 -0.2471 -0.0000 +0.0000 +1.0000 +0.0000 -0.2263 -2.0882 -0.6958 +0.4428 +1.0000 +0.0000 +0.0000 +0.0000 +0.5957 -2.3363 -1.4111 +0.9384 +0.0000 +1.0000 -0.0000 -0.0000 +0.3923 -3.0599 -1.9884 -0.3303 See above for the function code: sort_r_mR(); AID: After sort_r_mR(); +1.0000 +0.0000 +0.0000 +0.0000 +0.5957 -2.3363 -1.4111 +0.9384 +0.0000 +1.0000 -0.0000 -0.0000 +0.3923 -3.0599 -1.9884 -0.3303 -0.0000 +0.0000 +1.0000 +0.0000 -0.2263 -2.0882 -0.6958 +0.4428 +0.0000 +0.0000 +0.0000 +1.0000 +0.2946 +1.2943 +1.3303 -0.2471 Press return to continue Press X return to stop