Linear Algebra and the C Language/a0cy
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC5
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA] ={
+0.329527604306, -0.365886364507, -0.067047239569, +0.001915635416, -0.287345312440,
-0.365886364507, +0.800330583940, -0.036588636451, +0.001045389613, -0.156808441932,
-0.067047239569, -0.036588636451, +0.993295276043, +0.000191563542, -0.028734531244,
+0.001915635416, +0.001045389613, +0.000191563542, +0.999994526756, +0.000820986607,
-0.287345312440, -0.156808441932, -0.028734531244, +0.000820986607, +0.876852008954
};
double v[RCA*RCA] ={
-0.479027840775, -0.099503719020, +0.002857131195, -0.393919298579, +0.818823787938,
+0.877799708227, +0.000000000000, +0.000000000000, +0.000000000000, +0.446843838561,
+0.000000000000, +0.995037190210, +0.000000000000, +0.000000000000, +0.081882378794,
+0.000000000000, +0.000000000000, +0.999995918392, +0.000000000000, -0.002339496537,
+0.000000000000, +0.000000000000, +0.000000000000, +0.919145030018, +0.350924480545
};
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 = i_mR(RCA,RCA);
double **T = i_mR(RCA,RCA);
clrscrn();
printf(" A :");
p_mR(A, S8,P6, C5);
printf(" V :");
p_mR(V, S9,P6, C5);
printf(" EValue = invV * A * V");
mul_mR(invV,A,T);
mul_mR(T,V,EValue);
p_mR(EValue, S9,P6, C5);
stop();
clrscrn();
printf(" A :");
p_mR(A, S8,P6, C5);
printf(" A = V * EValue * invV (Just verify the computation)");
mul_mR(V,EValue,T);
mul_mR(T,invV,A);
p_mR(A, S8,P6, C5);
stop();
clrscrn();
printf(" V1 V2 V3 V4 V5 :");
p_mR(V, S9,P6, C5);
printf(" EValue1 EValue2 EValue3 EValue4 EValue5 ");
p_mR(EValue, S9,P6, C5);
printf(" det(V) = %.3e\n"
" det(V) != 0.00 V1,V2,V3,V4 and V5 are linearly independent\n\n",
det_R(V));
stop();
clrscrn();
printf(" The matrix A projects the space in the direction\n"
" of the eigenvector V5 on a hyperplan determined\n"
" by the eigenvector V1,V2,V3 and V4 if :\n\n"
" The eigenvector V1 has its eigenvalue equal to one and \n"
" The eigenvector V2 has its eigenvalue equal to one and \n"
" The eigenvector V3 has its eigenvalue equal to one and \n"
" The eigenvector V4 has its eigenvalue equal to one and \n"
" The eigenvector V5 has its eigenvalue equal to zero and \n\n"
" If The vectors V1,V2,V3,V4 and V5 are linearly independent\n\n");
stop();
f_mR(A);
f_mR(V);
f_mR(invV);
f_mR(T);
f_mR(EValue);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
+0.329528 -0.365886 -0.067047 +0.001916 -0.287345
-0.365886 +0.800331 -0.036589 +0.001045 -0.156808
-0.067047 -0.036589 +0.993295 +0.000192 -0.028735
+0.001916 +0.001045 +0.000192 +0.999995 +0.000821
-0.287345 -0.156808 -0.028735 +0.000821 +0.876852
V :
-0.479028 -0.099504 +0.002857 -0.393919 +0.818824
+0.877800 +0.000000 +0.000000 +0.000000 +0.446844
+0.000000 +0.995037 +0.000000 +0.000000 +0.081882
+0.000000 +0.000000 +0.999996 +0.000000 -0.002339
+0.000000 +0.000000 +0.000000 +0.919145 +0.350924
EValue = invV * A * V
+1.000000 -0.000000 +0.000000 -0.000000 +0.000000
-0.000000 +1.000000 +0.000000 -0.000000 +0.000000
+0.000000 +0.000000 +1.000000 +0.000000 -0.000000
-0.000000 -0.000000 +0.000000 +1.000000 -0.000000
-0.000000 -0.000000 +0.000000 -0.000000 -0.000000
Press return to continue.
A :
+0.329528 -0.365886 -0.067047 +0.001916 -0.287345
-0.365886 +0.800331 -0.036589 +0.001045 -0.156808
-0.067047 -0.036589 +0.993295 +0.000192 -0.028735
+0.001916 +0.001045 +0.000192 +0.999995 +0.000821
-0.287345 -0.156808 -0.028735 +0.000821 +0.876852
A = V * EValue * invV (Just verify the computation)
+0.329528 -0.365886 -0.067047 +0.001916 -0.287345
-0.365886 +0.800331 -0.036589 +0.001045 -0.156808
-0.067047 -0.036589 +0.993295 +0.000192 -0.028735
+0.001916 +0.001045 +0.000192 +0.999995 +0.000821
-0.287345 -0.156808 -0.028735 +0.000821 +0.876852
Press return to continue.
V1 V2 V3 V4 V5 :
-0.479028 -0.099504 +0.002857 -0.393919 +0.818824
+0.877800 +0.000000 +0.000000 +0.000000 +0.446844
+0.000000 +0.995037 +0.000000 +0.000000 +0.081882
+0.000000 +0.000000 +0.999996 +0.000000 -0.002339
+0.000000 +0.000000 +0.000000 +0.919145 +0.350924
EValue1 EValue2 EValue3 EValue4 EValue5
+1.000000 -0.000000 +0.000000 -0.000000 +0.000000
-0.000000 +1.000000 +0.000000 -0.000000 +0.000000
+0.000000 +0.000000 +1.000000 +0.000000 -0.000000
-0.000000 -0.000000 +0.000000 +1.000000 -0.000000
-0.000000 -0.000000 +0.000000 -0.000000 -0.000000
det(V) = 9.805e-01
det(V) != 0.00 V1,V2,V3,V4 and V5 are linearly independent
Press return to continue.
The matrix A projects the space in the direction
of the eigenvector V5 on a hyperplan determined
by the eigenvector V1,V2,V3 and V4 if :
The eigenvector V1 has its eigenvalue equal to one and
The eigenvector V2 has its eigenvalue equal to one and
The eigenvector V3 has its eigenvalue equal to one and
The eigenvector V4 has its eigenvalue equal to one and
The eigenvector V5 has its eigenvalue equal to zero and
If The vectors V1,V2,V3,V4 and V5 are linearly independent
Press return to continue.