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

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" /* ------------------------------------ */ #define RA R5 #define CA C3 /* ------------------------------------ */ int main(void) { double a[RA*CA]={ +2, +7, +4, -9, -3, +2, -4, -4, +2, -7, +8, -9, +2, -2, -1 }; double **A = ca_A_mR(a,i_mR(RA,CA)); double **Q = i_mR(RA,CA); double **R = i_mR(CA,CA); clrscrn(); printf(" A :"); p_mR(A,S3,P0,C6); printf(" Copy/Paste into the octave windows \n\n"); p_Octave_mR(A,"a",P0); printf(" [Q, R] = qr (a,0) \n\n"); stop(); clrscrn(); QR_mR(A,Q,R); printf(" Q :"); p_mR(Q,S10,P4,C6); printf(" R :"); p_mR(R,S10,P4,C6); stop(); clrscrn(); printf(" A :"); p_mR(A,S3,P0,C6); printf(" A = Q * R :"); mul_mR(Q,R, A); p_mR(A,S10,P4,C6); stop(); f_mR(A); f_mR(Q); f_mR(R); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A : +2 +7 +4 -9 -3 +2 -4 -4 +2 -7 +8 -9 +2 -2 -1 Copy/Paste into the octave windows a=[ +2,+7,+4; -9,-3,+2; -4,-4,+2; -7,+8,-9; +2,-2,-1] [Q, R] = qr (a,0) Press return to continue. Q : +0.1612 +0.5908 +0.7252 -0.7252 -0.2665 +0.3849 -0.3223 -0.3423 +0.1799 -0.5641 +0.6600 -0.4684 +0.1612 -0.1646 -0.2724 R : +12.4097 -0.2417 +3.4650 +0.0000 +11.9139 -4.6301 -0.0000 -0.0000 +8.5180 Press return to continue. A : +2 +7 +4 -9 -3 +2 -4 -4 +2 -7 +8 -9 +2 -2 -1 A = Q * R : +2.0000 +7.0000 +4.0000 -9.0000 -3.0000 +2.0000 -4.0000 -4.0000 +2.0000 -7.0000 +8.0000 -9.0000 +2.0000 -2.0000 -1.0000 Press return to continue