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

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" /* ------------------------------------ */ 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 **EVector = eigs_V_mR(A, i_mR(rc,rc)); double **UmnsEVector = sub_mR(U,EVector, 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); printf(" EVector:"); p_mR(EVector,S5,P5,C10); stop(); clrscrn(); printf(" U :"); p_mR(U,S5,P5,C10); printf(" EVector:"); p_mR(EVector,S5,P5,C10); printf(" U - EVector: When A is symetric U == EVector"); p_mR(UmnsEVector,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 the eigenvector are equal when the matrix A is symmetric. Screen output example: Copy/Paste into the octave windows A=[ -4.00,+1.00,-9.00,+2.00; +1.00,+8.00,+6.00,-3.00; -9.00,+6.00,+5.00,+6.00; +2.00,-3.00,+6.00,+6.00] [U, S, V] =svd (A,10) Press return to continue. U : -0.30730 +0.72168 -0.04535 +0.61862 +0.50274 -0.24907 -0.66609 +0.49148 +0.75922 +0.56858 +0.15782 -0.27458 +0.27641 -0.30637 +0.72757 +0.54806 S : +14.80035 +12.28485 +9.92334 +2.56116 V: -0.30730 +0.72168 -0.04535 +0.61862 +0.50274 -0.24907 -0.66609 +0.49148 +0.75922 +0.56858 +0.15782 -0.27458 +0.27641 -0.30637 +0.72757 +0.54806 EVector: -0.30730 +0.72168 -0.04535 +0.61862 +0.50274 -0.24907 -0.66609 +0.49148 +0.75922 +0.56858 +0.15782 -0.27458 +0.27641 -0.30637 +0.72757 +0.54806 Press return to continue. U : -0.30730 +0.72168 -0.04535 +0.61862 +0.50274 -0.24907 -0.66609 +0.49148 +0.75922 +0.56858 +0.15782 -0.27458 +0.27641 -0.30637 +0.72757 +0.54806 EVector: -0.30730 +0.72168 -0.04535 +0.61862 +0.50274 -0.24907 -0.66609 +0.49148 +0.75922 +0.56858 +0.15782 -0.27458 +0.27641 -0.30637 +0.72757 +0.54806 U - EVector: When A is symetric U == EVector -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