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

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: c00d.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RCA C2 #define P 17/* Try : 10, 15, 20, 25 */ /* ------------------------------------ */ /* ------------------------------------ */ double f( double x) { return(pow(x,P)); } char feq[] = "x**P"; /* ------------------------------------ */ /* ------------------------------------ */ int main(void) { double a[RCA*RCA]={ +0.8,+0.3, +0.2,+0.7 }; double **A = ca_A_mR(a, i_mR(RCA,RCA)); double **A_P = pow_mR(P, A, i_mR(RCA,RCA)); double **Ev = eigs_V_mR(A, i_mR(RCA,RCA)); double **InvEv = invgj_mR(Ev, i_mR(RCA,RCA)); /* Eval = InvEv A Ev */ double **T = mul_mR(InvEv, A, i_mR(RCA,RCA)); double **Eval = mul_mR(T, Ev, i_mR(RCA,RCA)); double **f_Eval = i_mR(RCA,RCA); clrscrn(); printf(" Copy/Paste into the octave windows \n"); p_Octave_mR(A,"A",P9); printf(" A^%d\n\n",P); printf(" A^%d:",P); pE_mR(A_P,S10,P4,C6); printf(" A^%d: Ev Eval**%d InvEv",P,P); f_eigs_mR(f,Eval,f_Eval); mul_mR(Ev,f_Eval,T); mul_mR(T,InvEv,A_P); pE_mR(A_P,S10,P4,C6); stop(); f_mR(A); f_mR(A_P); f_mR(Ev); f_mR(InvEv); f_mR(Eval); f_mR(f_Eval); f_mR(T); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: Copy/Paste into the octave windows A=[ +0.800000000,+0.300000000; +0.200000000,+0.700000000] A^17 A^17: +6.0000e-01 +6.0000e-01 +4.0000e-01 +4.0000e-01 A^17: Ev Eval**17 InvEv +6.0000e-01 +6.0000e-01 +4.0000e-01 +4.0000e-01 Press return to continue.