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

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 rc) { double **A = rsymmetric_mR( i_mR(rc,rc),9.); double **A_T = transpose_mR(A, i_mR(rc,rc)); double **S = svds_mR(A, i_mR(rc,C1)); double **U = svd_U_Rn_mR(A_T, i_mR(rc,rc)); double **V = svd_V_Rn_mR(A_T, i_mR(rc,rc)); double **UmnsV = sub_mR(U,V, i_mR(rc,rc)); 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(" U :"); p_mR(U,S5,P5,C10); printf(" S :"); p_mR(S,S5,P5,C10); printf(" V:"); p_mR(V,S5,P5,C10); stop(); clrscrn(); printf(" U :"); p_mR(U,S5,P5,C10); printf(" V:"); p_mR(V,S5,P5,C10); printf(" U - V: When A is symetric U == V"); p_mR(UmnsV,S5,P5,C10); f_mR(A_T); f_mR(A); f_mR(S); f_mR(U); f_mR(V); } /* ------------------------------------ */ 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 vectors U and V are equal when the matrix A is symmetric. Screen output example: Copy/Paste into the octave windows A=[ +3.00,+7.00,+5.00,-9.00; +7.00,-3.00,-1.00,-5.00; +5.00,-1.00,-3.00,+5.00; -9.00,-5.00,+5.00,-2.00] [U, S, V] =svd (A,10) Press return to continue. U : +0.72034 +0.55030 -0.24242 +0.34572 +0.44644 -0.12799 +0.87872 -0.11031 +0.02942 -0.55651 +0.00823 +0.83028 -0.53004 +0.60917 +0.41112 +0.42302 S : +14.16500 +13.64738 +7.27986 +1.76223 V: +0.72034 +0.55030 -0.24242 +0.34572 +0.44644 -0.12799 +0.87872 -0.11031 +0.02942 -0.55651 +0.00823 +0.83028 -0.53004 +0.60917 +0.41112 +0.42302 Press return to continue. U : +0.72034 +0.55030 -0.24242 +0.34572 +0.44644 -0.12799 +0.87872 -0.11031 +0.02942 -0.55651 +0.00823 +0.83028 -0.53004 +0.60917 +0.41112 +0.42302 V: +0.72034 +0.55030 -0.24242 +0.34572 +0.44644 -0.12799 +0.87872 -0.11031 +0.02942 -0.55651 +0.00823 +0.83028 -0.53004 +0.60917 +0.41112 +0.42302 U - V: When A is symetric U == V +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 +0.00000 Press return to continue Press X return to stop