411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0pf
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 C2
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+0,+1,
-1./2.,+3./2.
};
double **A = ca_A_mR(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 **T1 = mul_mR(InvEv, A, i_mR(RCA,RCA));
double **Eval = mul_mR(T1, Ev, i_mR(RCA,RCA));
clrscrn();
printf(" Copy/Paste into the octave windows \n");
p_Octave_mR(A,"a",P9);
printf(" [V, E] = eigs (a,%d) \n\n",RCA);
printf(" Ev:");
p_mR(Ev,S10,P4,C6);
printf(" Eval = InvEv A Ev");
p_mR(Eval,S10,P4,C6);
stop();
f_mR(A);
f_mR(Ev);
f_mR(InvEv);
f_mR(Eval);
f_mR(T1);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
Copy/Paste into the octave windows
a=[
+0.000000000,+1.000000000;
-0.500000000,+1.500000000]
[V, E] = eigs (a,2)
Ev:
+0.7071 +0.8944
+0.7071 +0.4472
Eval = InvEv A Ev
+1.0000 -0.0000
+0.0000 +0.5000
Press return to continue.