Linear Algebra and the C Language/a0hx
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00e.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rlower_mR(i_mR(r,r),999.);
double **EigsVector= i_mR(r,r);
double **EigsValue = i_mR(r,C1);
clrscrn();
printf(" Copy/Paste into the octave windows \n\n");
p_Octave_mR(A,"a",P0);
printf(" [V, E] = eigs (a,%d) \n\n",r);
stop();
clrscrn();
printf(" A:");
p_mR(A ,S5,P0,C6);
eigs_V_mR(A,EigsVector);
printf(" EigsVector:");
p_mR(EigsVector ,S5,P4,C6);
eigs_mR(A,EigsValue);
printf(" EigsValue:");
p_mR(EigsValue ,S13,P4,C1);
f_mR(A);
f_mR(EigsVector);
f_mR(EigsValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R3)+R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
* Eigenvalues and eigenvectors of a lower triangular matrix * I check that the eigenvalues of the lower triangular matrix A correspond to the values found on the diagonal. They can be in a different order.
Screen output example:
Copy/Paste into the octave windows
a=[
-330,+0,+0,+0,+0;
+864,-659,+0,+0,+0;
-95,+905,-764,+0,+0;
-531,-951,-303,-279,+0;
+146,+78,-299,-845,+269]
[V, E] = eigs (a,5)
Press return to continue.
A:
-330 +0 +0 +0 +0
+864 -659 +0 +0 +0
-95 +905 -764 +0 +0
-531 -951 -303 -279 +0
+146 +78 -299 -845 +269
EigsVector:
+0.0000 -0.0000 +0.0063 +0.0000 +0.0000
-0.0000 +0.0588 +0.0166 +0.0000 +0.0000
+0.7017 +0.5068 +0.0332 +0.0000 +0.0000
+0.4384 +0.5512 +0.5718 +0.5441 -0.0000
+0.5617 +0.6602 +0.8195 +0.8390 +1.0000
EigsValue:
-764.0000
-659.0000
-330.0000
-279.0000
+269.0000
Press return to continue
Press X return to stop