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

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 : c00a.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RCA RC5 /* ------------------------------------ */ void fun(void) { /* Choose your Eigenvalues */ double d[RCA*RCA] ={ +1, +0, +0, +0, +0, +0, +2, +0, +0, +0, +0, +0, +3, +0, +0, +0, +0, +0, +4, +0, +0, +0, +0, +0, +5 }; double **D = ca_A_mR(d, i_mR(RCA,RCA)); double **A = rdefpos_diag_mR(D, i_mR(RCA,RCA),9); double **invA = invgj_mR(A, i_mR(RCA,RCA)); double **AinvA = mul_mR(A,invA, i_mR(RCA,RCA)); double **EigsValue = eigs_mR(A, i_mR(RCA,C1)); double cond = EigsValue[R1][C1] / EigsValue[RCA][C1]; /* maxi value mini value */ clrscrn(); printf(" Copy/Paste into the octave windows \n\n"); p_Octave_mR(A,"a",P12); printf(" EigenValues = eigs (a,%d) \n\n",RCA); printf(" EigenValues: cond = EvalueMax / EvalueMin = %.e",cond); p_mR(EigsValue, S13,P8,C1); stop(); clrscrn(); printf(" invA:"); p_mR(invA, S13,P4,C5); printf(" cond = EvalueMax / EvalueMin = %.e\n\n" " Id == A invA:",cond); p_mR(AinvA, S13,P9,C5); f_mR(A); f_mR(D); f_mR(invA); f_mR(AinvA); f_mR(EigsValue); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do fun(); while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ With up to 9 digits after the decimal point there does not appear to be any error. Screen output example: Copy/Paste into the octave windows a=[ +4.051099628878,-0.122230950769,-0.459733289764,-0.444765749693,+0.91156044032;, -0.122230950769,+2.480595148028,+0.022569544826,-0.892483514917,+0.47253420844;, -0.459733289764,+0.022569544826,+2.889454033608,-1.010436504557,-0.55158622590;, -0.444765749693,-0.892483514917,-1.010436504557,+2.438620373951,-0.73387996551;, +0.911560440321,+0.472534208441,-0.551586225903,-0.733879965517,+3.14023081553], EigenValues = eigs (a,5) EigenValues: cond = EvalueMax / EvalueMin = 5e+00 +5.00000000 +4.00000000 +3.00000000 +2.00000000 +1.00000000 Press return to continue. invA: +0.2769 +0.0518 +0.0586 +0.0756 -0.0602 +0.0518 +0.4853 +0.0725 +0.2092 -0.0264 +0.0586 +0.0725 +0.4708 +0.2676 +0.1173 +0.0756 +0.2092 +0.2676 +0.6555 +0.1468 -0.0602 -0.0264 +0.1173 +0.1468 +0.3948 cond = EvalueMax / EvalueMin = 5e+00 Id == A invA: +1.000000000 -0.000000000 -0.000000000 -0.000000000 -0.000000000 -0.000000000 +1.000000000 -0.000000000 +0.000000000 -0.000000000 +0.000000000 +0.000000000 +1.000000000 +0.000000000 +0.000000000 +0.000000000 +0.000000000 +0.000000000 +1.000000000 +0.000000000 +0.000000000 +0.000000000 -0.000000000 +0.000000000 +1.000000000 Press return to continue Press X return to stop