Linear Algebra and the C Language/a0lx
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c01d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC3
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+8.146673651126, +0.924044002095, +1.085385018334,
+0.924044002095, +13.821477213201, +6.837925615505,
+1.085385018334, +6.837925615506, +16.031849135673
};
double v[RCA*RCA]={
+0.102355700213, -0.987635528464, -0.990992430410,
+0.644840911344, +0.156767544201, +0.000000000000,
+0.757432181579, +0.000000000000, +0.133917896001
};
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");
stop();
clrscrn();
printf(" A:");
p_mR(A, S9,P5, C4);
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.
Press return to continue.
A:
+8.14667 +0.92404 +1.08539
+0.92404 +13.82148 +6.83793
+1.08539 +6.83793 +16.03185
V:
+0.10236 -0.98764 -0.99099
+0.64484 +0.15677 +0.00000
+0.75743 +0.00000 +0.13392
EValue = invV A V
+22.00000 +0.00000 +0.00000
+0.00000 +8.00000 +0.00000
+0.00000 +0.00000 +8.00000
A = V EValue invV
+8.14667 +0.92404 +1.08539
+0.92404 +13.82148 +6.83793
+1.08539 +6.83793 +16.03185
Press return to continue.