411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0p5
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 : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC3
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA] ={
+2.363636363638, -1.909090909092, -0.272727272727,
+1.818181818184, -1.545454545456, -0.363636363636,
-0.909090909092, +1.272727272728, +1.181818181818
};
double NVN[RCA*RCA] ={
+0.784464540553, -0.408248290464, -0.557086014531,
+0.588348405415, -0.408248290464, -0.742781352708,
-0.196116135138, +0.816496580928, +0.371390676354
};
double **A = ca_A_mR(a, i_mR(RCA,RCA));
double **Nvn = ca_A_mR(NVN, i_mR(RCA,RCA));
double **invNvn = invgj_mR(Nvn, i_mR(RCA,RCA));
double **EValue = i_mR(RCA,RCA);
double **T = i_mR(RCA,RCA);
clrscrn();
printf(" A :");
p_mR(A, S9,P12, C4);
printf(" Nvn :");
p_mR(Nvn, S9,P12, C4);
printf(" Verify if:\n\n"
" EValue = invNvn * A * Nvn\n\n"
" EValue 1 EValue 2 EValue 3");
mul_mR(invNvn,A,T);
mul_mR(T,Nvn,EValue);
p_mR(EValue, S9,P12, C4);
stop();
clrscrn();
printf(" A :");
p_mR(A, S9,P12, C4);
printf(" Verify if:\n\n"
" A = Nvn EValue invNvn");
mul_mR(Nvn,EValue,T);
mul_mR(T,invNvn,A);
p_mR(A, S8,P12, C3);
stop();
clrscrn();
printf(" det(Nvn) = %.3e\n"
" det(Nvn) != 0 V1 and V2 and V3 are linearly independent\n\n",
det_R(Nvn));
printf(" The matrix A projects the space in the direction\n"
" of the eigenvector V3 on a plan determined by\n"
" the eigenvector V1 and V2 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 zero and \n\n"
" If The vectors V1 and V2 and V3 are linearly independent\n\n");
stop();
f_mR(A);
f_mR(Nvn);
f_mR(invNvn);
f_mR(T);
f_mR(EValue);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
You verify the properties of the matrix A.
* The values of the eigenvalues: EValue = invNvn A Nvn
* The matrix: A = Nvn EValue invNvn
* If the column vector of A are linearly independent
Screen output example:
A :
+2.363636363638 -1.909090909092 -0.272727272727
+1.818181818184 -1.545454545456 -0.363636363636
-0.909090909092 +1.272727272728 +1.181818181818
Nvn :
+0.784464540553 -0.408248290464 -0.557086014531
+0.588348405415 -0.408248290464 -0.742781352708
-0.196116135138 +0.816496580928 +0.371390676354
Verify if:
EValue = invNvn * A * Nvn
EValue 1 EValue 2 EValue 3
+1.000000000000 +0.000000000000 +0.000000000000
+0.000000000000 +1.000000000000 +0.000000000000
-0.000000000000 +0.000000000000 +0.000000000000
Press return to continue.
A :
+2.363636363638 -1.909090909092 -0.272727272727
+1.818181818184 -1.545454545456 -0.363636363636
-0.909090909092 +1.272727272728 +1.181818181818
Verify if:
A = Nvn EValue invNvn
+2.363636363638 -1.909090909092 -0.272727272727
+1.818181818184 -1.545454545456 -0.363636363636
-0.909090909092 +1.272727272728 +1.181818181818
Press return to continue.
det(Nvn) = 1.635e-01
det(Nvn) != 0 V1 and V2 and V3 are linearly independent
The matrix A projects the space in the direction
of the eigenvector V3 on a plan determined by
the eigenvector V1 and V2 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 zero and
If The vectors V1 and V2 and V3 are linearly independent
Press return to continue.