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

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install this file in your working directory. /* ------------------------------------ */ /* Save as : vgj2piv.h */ /* ------------------------------------ */ double pivotbest_gj2Ab_mR( double **Ab, int pivot_r, int pivot_c ) { double pivotbest = fabs(Ab[pivot_r][pivot_c]); int best_r = pivot_r; int best_c = pivot_c; int r; int c; for ( r=pivot_r; r<Ab[R_SIZE ][C0]; r++) for ( c=pivot_c; c<Ab[C_SIZE_A][C0]; c++) if(fabs(Ab[r][c])>pivotbest) { pivotbest = fabs(Ab[r][c]); best_r = r; best_c = c; } if(best_r!=pivot_r) swapR_mR(Ab,pivot_r,best_r); if(best_c!=pivot_c) swapC_withR0_mR(Ab,pivot_c,best_c); return(pivotbest); } /* ------------------------------------ */ void zero_under_pivot_gj2Ab_mR( double **Ab, int pivot_r, int pivot_c ) { double pivot = Ab[pivot_r][pivot_c]; int r; if(fabs(pivot)>ERROR_E) { mulR_mR( Ab,(1./pivot),pivot_r); for( r=(pivot_r+C1); r<Ab[R_SIZE][C0]; r++) addR_mR( Ab,(-Ab[r][pivot_c]),pivot_r,r); } } /* ------------------------------------ */ double **zero_above_pivot_gj2Ab_mR( double **Ab, int pivot_r, int pivot_c ) { int r; if(fabs(Ab[pivot_r][pivot_c])>ERROR_E) for( r=(pivot_r-C1); r>=R1; r--) addR_mR( Ab,(-Ab[r][pivot_c]),pivot_r,r); return(Ab); } /* ------------------------------------ */ /* ------------------------------------ */ void zero4_under_all_pivot_mR( double **Ab ) { int r= R1; int c= C1; while((r<Ab[R_SIZE][C0]) && (c<Ab[C_SIZE_A][C0]) ) { if(fabs(pivotbest_gj2Ab_mR(Ab,r,r))>ERROR_E) zero_under_pivot_gj2Ab_mR(Ab,r,r); r++; } } /* ------------------------------------ */ /* ------------------------------------ */