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

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" /* ------------------------------------ */ #define ARRAY A3 #define RCA R3 /* ------------------------------------ */ 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]: +71.00 -1.00 -25.00 -1.00 +54.00 -82.00 -25.00 -82.00 -34.00 EValue of A[0]: +107.31 -86.14 +69.84 A[1]: +100.02 -14.46 +17.57 -42.03 -83.65 -0.21 +0.31 -33.17 +74.63 EValue of A[1]: +107.31 -86.14 +69.84 A[2]: +107.12 -129.37 -55.43 +44.14 -22.66 -100.32 +41.02 -138.32 +6.54 EValue of A[2]: +107.31 -86.14 +69.84 Similar matrices have the eigenvalues. Press return to continue Press X return to stop