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

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 : c00c.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ double **X_c_Ab_subArxr_mR( double **Ab, double **subA ) { int r; int c; for (r=R1; r<Ab[R_SIZE][C0]; r++) for (c=C1; c<Ab[R_SIZE][C0]; c++) subA[r][c] = Ab[r][c]; return(subA); } /* ------------------------------------ */ /* ------------------------------------ */ void fun(int r, int c) { double **Ab = r_mR(i_Abr_Ac_bc_mR(r,c,C1),999.); double **A = i_mR(r,c); double **subA = i_mR(r,r); clrscrn(); printf(" Ab :"); p_mR(Ab,S8,P0,C7); printf(" A : i_mR(r,c);"); p_mR(c_Ab_A_mR(Ab,A),S8,P0,C7); printf(" subA : i_mR(r,r); \t\t c_Ab_subArxr_mR(Ab,subA); "); p_mR(c_Ab_subArxr_mR(Ab,subA),S8,P0,C7); f_mR(A); f_mR(Ab); f_mR(subA); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(rp_I(R3)+R1, rp_I(R3)+R3); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Copy the submatrix of Ab into subA:Gauss-Jordan This function allows, for example, to make the det_mR() function believe that the matrix is ​​square. We can calculate the determinant of this submatrix. If it is not zero, the system Ab can be solved with the Total Pivoting algorithm. Screen output example: Ab : +630 -423 +365 -416 -402 -720 +164 +630 -178 +504 +689 -302 +302 -839 +546 -684 +974 +714 -644 +779 -155 A : i_mR(r,c); +630 -423 +365 -416 -402 -720 +630 -178 +504 +689 -302 +302 +546 -684 +974 +714 -644 +779 subA : i_mR(r,r); c_Ab_subArxr_mR(Ab,subA); +630 -423 +365 +630 -178 +504 +546 -684 +974 Press return to continue Press X return to stop