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

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 A7 #define RCA R4 /* ------------------------------------ */ void fun(void) { double **A[ARRAY]; double **P[ARRAY]; double **InvP[ARRAY]; double **T = i_mR(RCA,RCA); double **EValue = i_mR(RCA,C1); int i; for(i=A0; i<ARRAY; i++) { A[i] = i_mR(RCA,RCA); P[i] = r_mR( i_mR(RCA,RCA),999); InvP[i] = inv_mR(P[i], i_mR(RCA,RCA)); } rsymmetric_mR(A[0],99); for(i=A0; i<(ARRAY-C1); i++) { mul_mR(InvP[i],A[i],T); mul_mR(T,P[i],A[i+C1]); } clrscrn(); for(i=A0; i<ARRAY; i++) { printf(" A[%d]: ",i); p_mR(A[i],S9,P2,C6); printf(" EValue of A[%d]: ",i); eigs_mR(A[i],EValue); p_mR(EValue, S9,P2,C6); } printf(" Similar matrices have the eigenvalues.\n\n"); for(i=A0; i<ARRAY; i++) { f_mR(A[i]); f_mR(P[i]); f_mR(InvP[i]); } f_mR(T); f_mR(EValue); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do{ fun(); }while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Similar matrices have the same eigenvalues. Screen output example: A[0]: +29.00 -45.00 -61.00 +26.00 -45.00 -98.00 +89.00 -14.00 -61.00 +89.00 -81.00 -60.00 +26.00 -14.00 -60.00 -88.00 EValue of A[0]: -189.54 +107.36 -104.71 -51.10 A[1]: -137.79 -53.77 -17.01 +150.95 -12.26 -174.22 -64.25 +20.12 +37.28 -38.18 -82.25 +0.74 -60.33 -151.92 -81.94 +156.26 EValue of A[1]: -189.54 +107.36 -104.71 -51.10 A[2]: -189.52 +68.06 +292.44 -3.44 +727.03 -111.89 -746.32 -377.71 -174.92 +25.96 +127.25 +99.22 -193.73 +57.90 +387.09 -63.84 EValue of A[2]: -189.54 +107.36 -104.71 -51.10 A[3]: +20298.82 -7927.67 -20641.52 -15715.03 -2395.42 +802.70 +2445.27 +1745.92 +17125.00 -6623.76 -17413.19 -13231.80 +5059.63 -1994.54 -5143.43 -3926.33 EValue of A[3]: -189.54 +107.36 -104.71 -51.10 A[4]: +20010.44 +8138.76 -22440.97 -4230.77 -41846.82 -16838.42 +46687.10 +9291.57 +122.81 +132.06 -244.82 +176.15 +14133.35 +5677.81 -15743.70 -3165.20 EValue of A[4]: -189.54 +107.36 -104.71 -51.10 A[5]: -54190.38 +107565.56 -46558.01 -35268.90 -1576.91 +3006.19 -1418.52 -981.34 +26506.50 -52756.27 +22705.74 +17295.84 +43265.11 -86070.07 +37060.96 +28240.45 EValue of A[5]: -189.54 +107.36 -104.71 -51.10 A[6]: -1023802.05 +666779.69 +567451.61 -188381.02 -1635679.85 +1065229.31 +906511.53 -301019.92 +418107.11 -272277.39 -231691.71 +76955.50 +1033361.04 -673106.52 -572867.33 +190026.45 EValue of A[6]: -189.93 +107.93 -105.71 -50.25 Similar matrices have the eigenvalues. Press return to continue Press X return to stop