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

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 : c00c.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ void fun(int rc) { double **A = rdefinite_positive_mR( i_mR(rc,rc),9); double **S = svds_mR(A, i_mR(rc,C1)); double **EValue = eigs_mR(A, i_mR(rc,C1)); clrscrn(); printf(" Copy/Paste into the octave windows \n\n\n"); p_Octave_mR(A,"A",P2); printf(" [U, S, V] =svd (A,10)\n\n\n"); stop(); clrscrn(); printf(" S:"); p_mR(S,S5,P5,C10); printf(" EValue: If A is a Positive-definite" " matrix then EValue == S"); p_mR(EValue,S5,P5,C10); f_mR(A); f_mR(S); f_mR(EValue); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(rp_I(R3)+R1); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ You can verify numerically that the singularvalues and the eigenvalues are equal when A is a positive-definite matrix. Screen output example: Copy/Paste into the octave windows A=[ +5.06,+0.20,+0.48,-0.41; +0.20,+5.35,+0.49,-0.36; +0.48,+0.49,+4.96,+0.23; -0.41,-0.36,+0.23,+4.63] [U, S, V] =svd (A,10) Press return to continue. S: +6.00000 +5.00000 +5.00000 +4.00000 EValue: If A is a Positive-definite matrix then EValue == S +6.00000 +5.00000 +5.00000 +4.00000 Press return to continue Press X return to stop