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

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 Xdet_R( double **A ) { double **T = c_mR(A, i_RC_mR(A[R_SIZE][C0],A[C_SIZE][C0])); double SIGN = 1; double PIVOT = 1; double deter=1; int rc; /* ------------------------------------ */ for( rc=C1; rc<T[C_SIZE][C0]; rc++) { SIGN = pivotbest_mR(T,rc); deter *= SIGN; /* ------------------------------------ */ clrscrn(); printf(" deter *= pivotbest_mR(T,rc);\n\n" " SIGN = %+0.4f \n deter = %+0.4f\n\n\n",SIGN,deter); p_mR(T,S10,P4,C6); stop(); /* ------------------------------------ */ PIVOT = zero_under_pivot_mR(T,rc); deter *= PIVOT; /* ------------------------------------ */ clrscrn(); printf(" deter *= zero_under_pivot_mR(T,rc);\n\n" " PIVOT = %+0.4f\n" " deter *= PIVOT \n" " deter = %+0.4f\n",PIVOT,deter); p_mR(T,S10,P4,C6); if(rc+C1<T[C_SIZE][C0]) stop(); /* ------------------------------------ */ } f_mR(T); return(deter); } /* ------------------------------------ */ /* ------------------------------------ */ void fun(void) { double **A = r_mR(i_mR(R4,R4),999); clrscrn(); printf(" Copy/Paste into the octave window. \n\n"); p_Octave_mR(A,"A",P1); printf(" det(A)\n\n\n"); stop(); printf(" det(A) = %.4e\n",Xdet_R(A)); f_mR(A); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: Copy/Paste into the octave window. A=[ -403.0,+533.0,-613.0,+980.0; -166.0,-686.0,+431.0,+534.0; +534.0,+897.0,-248.0,-705.0; +508.0,+707.0,-506.0,+272.0] det(A) Press return to continue. deter *= pivotbest_mR(T,rc); SIGN = -1.0000 deter = -1.0000 +980.0000 +533.0000 -613.0000 -403.0000 +534.0000 -686.0000 +431.0000 -166.0000 -705.0000 +897.0000 -248.0000 +534.0000 +272.0000 +707.0000 -506.0000 +508.0000 Press return to continue. deter *= zero_under_pivot_mR(T,rc); PIVOT = +980.0000 deter *= PIVOT deter = -980.0000 +1.0000 +0.5439 -0.6255 -0.4112 +0.0000 -976.4306 +765.0224 +53.5939 +0.0000 +1280.4337 -688.9847 +244.0867 +0.0000 +559.0653 -335.8612 +619.8531 Press return to continue. deter *= pivotbest_mR(T,rc); SIGN = -1.0000 deter = +980.0000 +1.0000 +0.5439 -0.6255 -0.4112 +0.0000 +1280.4337 -688.9847 +244.0867 +0.0000 -976.4306 +765.0224 +53.5939 +0.0000 +559.0653 -335.8612 +619.8531 Press return to continue. deter *= zero_under_pivot_mR(T,rc); PIVOT = +1280.4337 deter *= PIVOT deter = +1254825.0000 +1.0000 +0.5439 -0.6255 -0.4112 +0.0000 +1.0000 -0.5381 +0.1906 +0.0000 +0.0000 +239.6178 +239.7291 +0.0000 +0.0000 -35.0355 +513.2795 Press return to continue. deter *= pivotbest_mR(T,rc); SIGN = +1.0000 deter = +1254825.0000 +1.0000 +0.5439 -0.4112 -0.6255 +0.0000 +1.0000 +0.1906 -0.5381 +0.0000 +0.0000 +513.2795 -35.0355 +0.0000 +0.0000 +239.7291 +239.6178 Press return to continue. deter *= zero_under_pivot_mR(T,rc); PIVOT = +513.2795 deter *= PIVOT deter = +644075901.0000 +1.0000 +0.5439 -0.4112 -0.6255 +0.0000 +1.0000 +0.1906 -0.5381 +0.0000 +0.0000 +1.0000 -0.0683 +0.0000 +0.0000 +0.0000 +255.9813 Press return to continue. deter *= pivotbest_mR(T,rc); SIGN = +1.0000 deter = +644075901.0000 +1.0000 +0.5439 -0.4112 -0.6255 +0.0000 +1.0000 +0.1906 -0.5381 +0.0000 +0.0000 +1.0000 -0.0683 +0.0000 +0.0000 +0.0000 +255.9813 Press return to continue. deter *= zero_under_pivot_mR(T,rc); PIVOT = +255.9813 deter *= PIVOT deter = +164871377501.0002 +1.0000 +0.5439 -0.4112 -0.6255 +0.0000 +1.0000 +0.1906 -0.5381 +0.0000 +0.0000 +1.0000 -0.0683 +0.0000 +0.0000 +0.0000 +1.0000 det(A) = 1.6487e+11 Press return to continue Press X return to stop