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

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: c00d.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ /* ------------------------------------ */ double **X_invgj_pivot_mR( double **Ab ) { double pivot = 1.; int r= R1; while( pivot && (r<Ab[R_SIZE ][C0]) ) { clrscrn(); printf("/* --------- DEBUG 1 ---------- */\n"); printf(" AID:"); p_mR(Ab, S8,P4,C8); pivot = pivotbestAId_mR(Ab,r); printf(" pivot[%d][[%d] = %f \n\n" " pivotbestAId_mR(); \n" " zero_under_pivot_gj1Ab_mR();\n\n" ,r,r,pivot); printf(" AID:"); p_mR(Ab, S8,P4,C8); stop(); if(pivot>ERROR_E) zero_under_pivot_gj1Ab_mR(Ab,r); r++; } clrscrn(); printf(" pivotbestAId_mR(); \n" " zero_under_pivot_gj1Ab_mR();\n\n" " AID:\n"); p_mR(Ab, S8,P4,C8); /* --------------------------- while( (r>R1) ) { r--; zero_above_pivot_gj1Ab_mR(Ab,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); X_invgj_pivot_mR(AID); /* sort_c_mR(AID); */ /* v sort_r_mR(AID); */ /* 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(); printf(" A:"); p_mR(A, S3,P4,C6); stop(); 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: A: +0.0060 -0.2050 -0.5100 -0.2720 -0.0180 -0.0040 -0.6080 -0.8670 -0.6000 -0.7490 +0.1190 +0.5800 -0.8520 -0.5360 +0.0280 -0.8860 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: +0.0060 -0.2050 -0.5100 -0.2720 +1.0000 +0.0000 +0.0000 +0.0000 -0.0180 -0.0040 -0.6080 -0.8670 +0.0000 +1.0000 +0.0000 +0.0000 -0.6000 -0.7490 +0.1190 +0.5800 +0.0000 +0.0000 +1.0000 +0.0000 -0.8520 -0.5360 +0.0280 -0.8860 +0.0000 +0.0000 +0.0000 +1.0000 pivot[1][[1] = 0.886000 pivotbestAId_mR(); zero_under_pivot_gj1Ab_mR(); AID: -0.8860 -0.5360 +0.0280 -0.8520 +1.0000 +0.0000 +0.0000 +0.0000 -0.8670 -0.0040 -0.6080 -0.0180 +0.0000 +1.0000 +0.0000 +0.0000 +0.5800 -0.7490 +0.1190 -0.6000 +0.0000 +0.0000 +1.0000 +0.0000 -0.2720 -0.2050 -0.5100 +0.0060 +0.0000 +0.0000 +0.0000 +1.0000 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: +1.0000 +0.6050 -0.0316 +0.9616 -1.1287 -0.0000 -0.0000 -0.0000 +0.0000 +0.5205 -0.6354 +0.8157 -0.9786 +1.0000 +0.0000 +0.0000 +0.0000 -1.0999 +0.1373 -1.1577 +0.6546 +0.0000 +1.0000 +0.0000 +0.0000 -0.0404 -0.5186 +0.2676 -0.3070 +0.0000 +0.0000 +1.0000 pivot[2][[2] = 1.157743 pivotbestAId_mR(); zero_under_pivot_gj1Ab_mR(); AID: +1.0000 +0.9616 -0.0316 +0.6050 -1.1287 -0.0000 -0.0000 -0.0000 +0.0000 -1.1577 +0.1373 -1.0999 +0.6546 +0.0000 +1.0000 +0.0000 +0.0000 +0.8157 -0.6354 +0.5205 -0.9786 +0.0000 +0.0000 +1.0000 +0.0000 +0.2676 -0.5186 -0.0404 -0.3070 +1.0000 +0.0000 +0.0000 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: +1.0000 +0.9616 -0.0316 +0.6050 -1.1287 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -0.1186 +0.9500 -0.5654 -0.0000 -0.8637 -0.0000 +0.0000 +0.0000 -0.5386 -0.2545 -0.5173 +0.0000 +0.7046 +1.0000 +0.0000 +0.0000 -0.4869 -0.2946 -0.1557 +1.0000 +0.2311 +0.0000 pivot[3][[3] = 0.538639 pivotbestAId_mR(); zero_under_pivot_gj1Ab_mR(); AID: +1.0000 +0.9616 -0.0316 +0.6050 -1.1287 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -0.1186 +0.9500 -0.5654 -0.0000 -0.8637 -0.0000 +0.0000 +0.0000 -0.5386 -0.2545 -0.5173 +0.0000 +0.7046 +1.0000 +0.0000 +0.0000 -0.4869 -0.2946 -0.1557 +1.0000 +0.2311 +0.0000 Press return to continue. /* --------- DEBUG 1 ---------- */ AID: +1.0000 +0.9616 -0.0316 +0.6050 -1.1287 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -0.1186 +0.9500 -0.5654 -0.0000 -0.8637 -0.0000 -0.0000 -0.0000 +1.0000 +0.4724 +0.9604 -0.0000 -1.3081 -1.8565 +0.0000 +0.0000 +0.0000 -0.0646 +0.3119 +1.0000 -0.4057 -0.9039 pivot[4][[4] = 0.064646 pivotbestAId_mR(); zero_under_pivot_gj1Ab_mR(); AID: +1.0000 +0.9616 -0.0316 +0.6050 -1.1287 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -0.1186 +0.9500 -0.5654 -0.0000 -0.8637 -0.0000 -0.0000 -0.0000 +1.0000 +0.4724 +0.9604 -0.0000 -1.3081 -1.8565 +0.0000 +0.0000 +0.0000 -0.0646 +0.3119 +1.0000 -0.4057 -0.9039 Press return to continue. pivotbestAId_mR(); zero_under_pivot_gj1Ab_mR(); AID: +1.0000 +0.9616 -0.0316 +0.6050 -1.1287 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 -0.1186 +0.9500 -0.5654 -0.0000 -0.8637 -0.0000 -0.0000 -0.0000 +1.0000 +0.4724 +0.9604 -0.0000 -1.3081 -1.8565 -0.0000 -0.0000 -0.0000 +1.0000 -4.8243 -15.4689 +6.2764 +13.9818 Press return to continue Press X return to stop