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

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 : c00f.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ void fun(int r) { double **A = rupper_mR( i_mR(r,r),999.); double **EVector = i_mR(r,r); double **EValue = i_mR(r,C1); clrscrn(); printf(" Copy/Paste into the octave windows \n\n"); p_Octave_mR(A,"a",P0); printf(" [V, E] = eigs (a,%d) \n\n",r); stop(); clrscrn(); printf(" A:"); p_mR(A ,S5,P0,C6); eigs_V_mR(A,EVector); printf(" EVector:"); p_mR(EVector ,S5,P4,C6); eigs_mR(A,EValue); printf(" EValue:"); p_mR(EValue ,S13,P4,C1); f_mR(A); f_mR(EVector); f_mR(EValue); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(rp_I(R3)+R2); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ * Eigenvalues and ​​eigenvectors of a upper triangular matrix * I check that the eigenvalues ​​of the upper triangular matrix A correspond to the values ​​found on the diagonal. They can be in a different order. Screen output example: Copy/Paste into the octave windows a=[ -75,-700,+904,+697,-245; +0,+125,+914,+914,+659; +0,+0,-160,-687,-702; +0,+0,+0,+108,+812; +0,+0,+0,+0,+138] [V, E] = eigs (a,5) Press return to continue. A: -75 -700 +904 +697 -245 +0 +125 +914 +914 +659 +0 +0 -160 -687 -702 +0 +0 +0 +108 +812 +0 +0 +0 +0 +138 EVector: +1.0000 +0.9615 +0.9959 +0.9691 +0.9548 +0.0000 -0.2747 +0.0862 -0.2466 -0.2971 +0.0000 -0.0000 -0.0269 +0.0075 -0.0074 +0.0000 +0.0000 +0.0000 -0.0029 +0.0031 +0.0000 +0.0000 +0.0000 +0.0000 +0.0001 EValue: -75.0000 +125.0000 -160.0000 +108.0000 +138.0000 Press return to continue Press X return to stop