Linear Algebra and the C Language/a0m7
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c03d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC4
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+9.387051138013, +1.478424899325, +0.973685336456, -0.700350180421,
+1.478424899325, +9.614194406175, +0.773429774749, -1.033063523876,
+0.973685336456, +0.773429774749, +10.505111304292, +1.482769644746,
-0.700350180421, -1.033063523876, +1.482769644746, +10.493643151520
};
double v[RCA*RCA]={
+0.545516920109, -0.502145306797, -0.756196931416, -0.703339481002,
+0.544568195031, -0.586388346015, +0.647558469922, +0.704564811108,
+0.637068890180, +0.000000000000, +0.093990579046, +0.000000000000,
+0.000000000000, +0.635608998142, +0.000000000000, +0.094350418183
};
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:
+9.38705 +1.47842 +0.97369 -0.70035
+1.47842 +9.61419 +0.77343 -1.03306
+0.97369 +0.77343 +10.50511 +1.48277
-0.70035 -1.03306 +1.48277 +10.49364
Press return to continue.
V:
+0.54552 -0.50215 -0.75620 -0.70334
+0.54457 -0.58639 +0.64756 +0.70456
+0.63707 +0.00000 +0.09399 +0.00000
+0.00000 +0.63561 +0.00000 +0.09435
EValue = invV A V
+12.00000 +0.00000 +0.00000 +0.00000
+0.00000 +12.00000 +0.00000 +0.00000
+0.00000 +0.00000 +8.00000 +0.00000
+0.00000 +0.00000 +0.00000 +8.00000
A = V EValue invV
+9.38705 +1.47842 +0.97369 -0.70035
+1.47842 +9.61419 +0.77343 -1.03306
+0.97369 +0.77343 +10.50511 +1.48277
-0.70035 -1.03306 +1.48277 +10.49364
Press return to continue.