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

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" /* ------------------------------------ */ void fun(int r,int rn) { double **A = r_mR( i_mR(r+rn,r),9); double **A_T = transpose_mR(A, i_mR(r,r+rn)); double **A_TA = mul_mR(A_T,A, i_mR(r,r)); double **SvdValue_2 = eigs_mR(A_TA, i_mR(r,C1)); double **SvdValue = sqrt_svd_mR(SvdValue_2, i_mR(r,C1)); clrscrn(); printf(" A :"); p_mR(A,S5,P0,C6); printf(" Copy/Paste into the octave windows \n\n\n"); p_Octave_mR(A,"a",P0); printf(" SvdValue = svd (a,10)\n\n\n"); stop(); clrscrn(); printf(" I calculate the square root of\n" " each eigenvalue and obtain the singular values.\n\n" " sqrt_svd_mR(SvdValue**2, SvdValue);\n\n" " SvdValue**2:"); p_mR(SvdValue_2,S13,P4,C1); printf(" SvdValue:"); p_mR(SvdValue,S13,P4,C1); f_mR(A); f_mR(A_T); f_mR(A_TA); f_mR(SvdValue_2); f_mR(SvdValue); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(rp_I(R4),rp0_I(R4)); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A : +5 +5 -3 +7 -1 +2 -6 -2 -4 -5 -6 -6 +2 +9 -2 +7 +4 -1 +9 -6 Copy/Paste into the octave windows a=[ +5,+5,-3,+7; -1,+2,-6,-2; -4,-5,-6,-6; +2,+9,-2,+7; +4,-1,+9,-6] SvdValue = svd (a,10) Press return to continue. I calculate the square root of each eigenvalue and obtain the singular values. sqrt_svd_mR(SvdValue**2, SvdValue); SvdValue**2: +316.5309 +183.3032 +25.5570 +12.6089 SvdValue: +17.7913 +13.5390 +5.0554 +3.5509 Press return to continue Press X return to stop Press X return to stop