Linear Algebra and the C Language/a0m3
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c02d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC4
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+5.701637292731, +0.991969965586, +0.254041088748, +1.125039107310,
+0.991969965586, +6.402440296173, +0.359161539264, +1.590572531025,
+0.254041088748, +0.359161539264, +5.091980394202, +0.407341745750,
+1.125039107310, +1.590572531025, +0.407341745750, +6.803942016894
};
double v[RCA*RCA]={
+0.418818962301, -0.816415639507, -0.340441083605, -0.848510478701,
+0.592123360495, +0.577464720627, +0.000000000000, +0.000000000000,
+0.151641348419, +0.000000000000, +0.940265849956, +0.000000000000,
+0.671554543000, +0.000000000000, +0.000000000000, +0.529178578114
};
double **A = ca_A_mR(a, i_mR(RCA,RCA));
double **V = ca_A_mR(v, i_mR(RCA,RCA));
double **invV = invgj_mR(V, i_mR(RCA,RCA));
double **EValue = eigs_mR(A, i_mR(RCA, RCA));
double **T = i_mR(RCA,RCA);
clrscrn();
printf(" The eigenvectors associated with eigenvalues\n"
" with multiple multiplicity are not unique. \n"
" There exist several set of unit vectors that\n"
" correspond to the same eigenspace. \n\n\n"
" An eigenvector associated with an eigenvalue\n"
" with single multiplicity is unique, up to a\n"
" change in the sign. \n\n\n");
printf(" A:");
p_mR(A, S9,P5, C4);
stop();
clrscrn();
printf(" V:");
p_mR(V, S9,P5, C4);
printf(" EValue = invV A V");
mul_mR(invV,A,T);
mul_mR(T,V,EValue);
p_mR(clean_eye_mR(EValue), S9,P5, C4);
printf(" A = V EValue invV");
mul_mR(V,EValue,T);
mul_mR(T,invV,A);
p_mR(A, S9,P5, C4);
stop();
f_mR(A);
f_mR(V);
f_mR(invV);
f_mR(T);
f_mR(EValue);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
The eigenvectors associated with eigenvalues
with multiple multiplicity are not unique.
There exist several set of unit vectors that
correspond to the same eigenspace.
An eigenvector associated with an eigenvalue
with single multiplicity is unique, up to a
change in the sign.
A:
+5.70164 +0.99197 +0.25404 +1.12504
+0.99197 +6.40244 +0.35916 +1.59057
+0.25404 +0.35916 +5.09198 +0.40734
+1.12504 +1.59057 +0.40734 +6.80394
Press return to continue.
V:
+0.41882 -0.81642 -0.34044 -0.84851
+0.59212 +0.57746 +0.00000 +0.00000
+0.15164 +0.00000 +0.94027 +0.00000
+0.67155 +0.00000 +0.00000 +0.52918
EValue = invV A V
+9.00000 +0.00000 +0.00000 +0.00000
+0.00000 +5.00000 +0.00000 +0.00000
+0.00000 +0.00000 +5.00000 +0.00000
+0.00000 +0.00000 +0.00000 +5.00000
A = V EValue invV
+5.70164 +0.99197 +0.25404 +1.12504
+0.99197 +6.40244 +0.35916 +1.59057
+0.25404 +0.35916 +5.09198 +0.40734
+1.12504 +1.59057 +0.40734 +6.80394
Press return to continue.