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

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_c_Ab_A_mR( double **Ab, double **A ) { int r; int c; for (r=R1; r<Ab[R_SIZE][C0]; r++) for (c=C1; c<Ab[C_SIZE_A][C0]; c++) A[r][c] = Ab[r][c]; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ double **X_c_Ab_b_mR( double **Ab, double **b ) { int r; int c; int b_c; for (r=R1; r<Ab[R_SIZE][C0]; r++) for (c=Ab[C_SIZE_A][C0],b_c=C1; c<Ab[C_SIZE][C0]; c++,b_c++) b[r][b_c] = Ab[r][c]; return(b); } /* ------------------------------------ */ /* ------------------------------------ */ void fun(int r, int c, int bc) { double **A = i_mR(r,c); double **b = i_mR(r,bc); double **Ab = r_mR(i_Abr_Ac_bc_mR(r,c,bc),99.); clrscrn(); printf(" Ab : Ab[R%d][C%d] \n", rsize_R(Ab), csize_R(Ab)); p_mR(Ab, S5,P0,C12); stop(); clrscrn(); printf(" A : c_Ab_A_mR(Ab,A); A[R%d][C%d] \n", rsize_R(Ab), csize_A_R(Ab)); p_mR(c_Ab_A_mR(Ab,A), S5,P0,C12); printf(" b : c_Ab_b_mR(Ab,b); b[R%d][C%d] \n", rsize_R(Ab), csize_R(Ab)-csize_A_R(Ab)); p_mR(c_Ab_b_mR(Ab,b), S5,P0,C12); f_mR(Ab); f_mR(b); f_mR(A); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(rp_I(R4)+R1, rp_I(R3)+R2, rp_I(R3)+R1); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Copy A from Ab to A, and b from Ab to b:Gauss-Jordan Screen output example: Ab : Ab[R3][C6] +21 +81 -30 +14 +85 +32 +9 -17 -47 +13 -70 -2 -22 +94 +79 -94 +40 +37 Press return to continue. A : c_Ab_A_mR(Ab,A); A[R3][C3] +21 +81 -30 +9 -17 -47 -22 +94 +79 b : c_Ab_b_mR(Ab,b); b[R3][C3] +14 +85 +32 +13 -70 -2 -94 +40 +37 Press return to continue Press X return to stop