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

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 : c00a.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ void fun(int r) { double **A = r_mR( i_mR(r,r),9.); double **B = r_mR( i_mR(r,r),9.); double **AB = mul_mR(A,B, i_mR(r,r)) ; double **BA = mul_mR(B,A, i_mR(r,r)) ; clrscrn(); printf(" A:"); p_mR(A, S3,P0,C6); printf(" B:"); p_mR(B, S3,P0,C6); stop(); clrscrn(); printf(" AB:"); p_mR(AB, S3,P0,C6); printf(" BA:"); p_mR(BA, S3,P0,C6); printf(" det(A) * det(B) = %+.0f\n",det_R(A)*det_R(B)); printf(" det(AB) = %+.0f\n",det_R(AB)); printf(" det(BA) = %+.0f\n",det_R(BA)); f_mR(A); f_mR(B); f_mR(AB); f_mR(BA); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(rp_I(RC4)+RC1); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ We can verify numerically that AB and BA have the same determinant equal to the products of the determinants of A and B. Screen output example: A: -9 +1 +7 +5 +9 +9 +8 -6 +3 -5 -8 -5 -8 -4 +2 -6 +3 -8 -6 -2 +6 -2 +9 -4 -9 B: +1 +6 +7 -6 +3 +7 +3 +1 +6 +1 +8 -3 -6 -7 -1 -3 +8 -4 -1 -4 +2 +8 +7 -2 -4 Press return to continue. AB: +57 +40 -61 -12 -89 -2 +80 +60 +43 +49 -91 -55 +17 +74 -13 -35 -67 +19 +120 +25 +58 -101 -61 -89 +59 BA: +43 -10 -10 +19 -22 -74 +42 -16 +0 +29 -15 -5 +169 +101 +98 +113 +86 -65 +47 -37 -14 +33 -110 +34 +32 det(A) * det(B) = -2979868760 det(AB) = -2979868760 det(BA) = -2979868760 Press return to continue Press X return to stop [modifier]