Linear Algebra and the C Language/a0d2
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA C5
/* ------------------------------------ */
void fun(void)
{
double **A = rsymmetric_mR( i_mR(RCA,RCA),9.);
double **EVector = eigs_V_mR(A, i_mR(RCA,RCA));
double **EVectorT = transpose_mR(EVector, i_mR(RCA,RCA));
double **T1 = mul_mR(EVectorT,A, i_mR(RCA,RCA));
double **EValue = mul_mR(T1,EVector, i_mR(RCA,RCA));
clrscrn();
printf(" Copy/Paste into the octave windows \n\n");
p_Octave_mR(A,"a",P0);
printf(" [V, E] = eigs (a,%d) \n\n",RCA);
stop();
clrscrn();
printf(" EVector:");
p_mR(EVector,S10,P4,C6);
printf(" EValue: EVectorT A EVector");
p_mR(EValue,S10,P4,C6);
f_mR(A);
f_mR(EVector);
f_mR(EVectorT);
f_mR(EValue);
f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
Copy/Paste into the octave windows
a=[
+2,-7,+7,-6,-9;
-7,-4,+2,-9,+8;
+7,+2,-7,+4,-9;
-6,-9,+4,+3,+2;
-9,+8,-9,+2,-8]
[V, E] = eigs (a,5)
Press return to continue.
EVector:
-0.1865 +0.6785 +0.6472 -0.2532 -0.1481
-0.5179 -0.3888 +0.2229 -0.4333 +0.5859
+0.5375 +0.3608 -0.0316 +0.0453 +0.7602
-0.3474 -0.0107 +0.2974 +0.8637 +0.2116
+0.5361 -0.5082 +0.6648 +0.0075 -0.1107
EValue: EVectorT A EVector
-22.9162 -0.0000 -0.0000 +0.0000 -0.0000
-0.0000 +16.5686 +0.0000 +0.0000 -0.0000
-0.0000 +0.0000 -12.7559 -0.0000 -0.0000
+0.0000 +0.0000 -0.0000 +9.5014 -0.0000
-0.0000 -0.0000 -0.0000 -0.0000 -4.3979
Press return to continue
Press X return to stop