Linear Algebra and the C Language/a0da
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rsymmetric_mR( i_mR(r,r),999);
double **EValue = eigs_mR(A, i_mR(r,C1));
double s = 0;
int i = 0;
clrscrn();
printf(" A:");
p_mR(A,S4,P0,C6);
printf(" EValue:");
p_mR(EValue,S13,P6,C1);
for(i=R1;i<=r;i++)
s += EValue[i][C1];
printf(" Sum of the eigenvalues of A: %.3f \n", s);
printf(" Trace of A : %.3f\n\n\n", trace_R(A));
f_mR(A);
f_mR(EValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R4)+R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A:
-485 -316 -930
-316 -179 +23
-930 +23 -430
EValue:
-1424.418748
+551.977363
-221.558615
Sum of the eigenvalues of A: -1094.000
Trace of A : -1094.000
Press return to continue
Press X return to stop