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

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" /* ------------------------------------ */ #define ARRAY A3 /* ------------------------------------ */ #define RC RC3 /* ------------------------------------ */ void fun(void) { double **A = rsymmetric_mR( i_mR(RC,RC),999); double **AEVect = eigs_V_mR(A, i_mR(RC,RC)); double **InvAEVect = transpose_mR(AEVect, i_mR(RC,RC)); double **AEValue = eigs_mR(A, i_mR(RC,C1)); double **T = i_mR(RC,RC); double **a = i_mR(RC,RC); double **b [ARRAY]; double **r [ARRAY]; double **br [ARRAY]; double **EVabr[ARRAY]; int i; for(i=A0; i<ARRAY; i++) { b[i] = c_c_mR( AEVect,i+C1, i_mR(RC,C1),C1); r[i] = c_r_mR(InvAEVect,i+R1, i_mR(R1,RC),R1); br[i] = mul_mR(b[i],r[i], i_mR(RC,RC)); EVabr[i] = smul_mR(AEValue[i+R1][C1], br[i], i_mR(RC,RC)); } clrscrn(); printf(" A:"); p_mR(A, S10,P4,C6); printf(" AEVect: Eigenvectors of A"); p_mR(AEVect, S10,P4,C6); printf(" AEValue: Eigenvalues of A"); p_mR(AEValue, S10,P4,C6); stop(); clrscrn(); printf(" A:"); p_mR(A, S10,P4,C6); add_mR(EVabr[0], EVabr[1], T); add_mR( T, EVabr[2], a); printf(" E1*b1r1 + E2*b2r2 + E3*b3r3 = A"); p_mR(a, S10,P4,C6); f_mR(A); f_mR(AEVect); f_mR(InvAEVect); f_mR(AEValue); f_mR(T); for(i=A0; i<ARRAY; i++) { f_mR( b[i]); f_mR( r[i]); f_mR( br[i]); f_mR(EVabr[i]); } } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ A property of spectral decomposition: E1 b1r1 + E2 b2r2 + E3 b3r3 = A b: The columns of the eigenvectors of A r: The rows of eigenvectors of the inverse of A E: The eignvalues of A. b1r1 is obtained by multiplying the first column of the eigenvector of A by the first row of the eigenvector of the inverse of A Screen output example: A: +333.0000 -413.0000 +924.0000 -413.0000 -118.0000 +712.0000 +924.0000 +712.0000 +870.0000 AEVect: Eigenvectors of A +0.5196 +0.5509 -0.6531 +0.2137 +0.6564 +0.7236 +0.8273 -0.5155 +0.2233 AEValue: Eigenvalues of A +1634.2674 -1023.8379 +474.5705 Press return to continue. A: +333.0000 -413.0000 +924.0000 -413.0000 -118.0000 +712.0000 +924.0000 +712.0000 +870.0000 E1*b1r1 + E2*b2r2 + E3*b3r3 = A +333.0000 -413.0000 +924.0000 -413.0000 -118.0000 +712.0000 +924.0000 +712.0000 +870.0000 Press return to continue Press X return to stop