Linear Algebra and the C Language/a0dd
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double s = rp_I(9);
double **A = rsymmetric_mR( i_mR(r, r),99.);
double **EigsValueA = eigs_mR(A, i_mR(r,C1) );
double **sA = smul_mR(s,A, i_mR(r, r));
double **EigsValuesA = eigs_mR(sA, i_mR(r,C1));
int i = 0;
clrscrn();
printf(" A :");
p_mR(A,S3,P0,C6);
printf(" EigsValue A :");
p_mR(EigsValueA,S13,P6,C1);
printf(" %.0f * A :",s);
p_mR(sA,S4,P0,C6);
printf(" EigsValue %.0f * A :",s);
p_mR(EigsValuesA,S13,P6,C1);
stop();
clrscrn();
printf(" EigsValue %.0f * A :",s);
p_mR(EigsValuesA,S13,P6,C1);
printf(" %.2f * EigsValues of A :\n",s);
for(i=R1;i<=r;i++)
printf(" %+12.6f \n", s*EigsValueA[i][C1]);
f_mR(A);
f_mR(EigsValueA);
f_mR(sA);
f_mR(EigsValuesA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R2)+R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
+1 -28 -27 -82
-28 -38 +75 +4
-27 +75 -40 +2
-82 +4 +2 -33
EigsValue A :
-114.066788
-103.093962
+89.053533
+18.107217
6 * A :
+6 -168 -162 -492
-168 -228 +450 +24
-162 +450 -240 +12
-492 +24 +12 -198
EigsValue 6 * A :
-684.400728
-618.563769
+534.321196
+108.643301
Press return to continue.
EigsValue 6 * A :
-684.400728
-618.563769
+534.321196
+108.643301
6.00 * EigsValues of A :
-684.400728
-618.563769
+534.321196
+108.643301
Press return to continue
Press X return to stop