Linear Algebra and the C Language/a0ii
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rdefinite_negative_mR( i_mR(r,r), 99);
double **invA = inv_mR(A, i_mR(r,r));
double **EValue = eigs_mR(invA, i_mR(r,C1));
clrscrn();
printf(" A: Definite negative");
p_mR(A,S12,P6,C6);
printf(" invA:");
p_mR(invA,S12,P6,C6);
printf(" Eigenvalues: eigs_mR(InvA,EValue);");
p_mR(EValue,S9,P3,C1);
f_mR(A);
f_mR(invA);
f_mR(EValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(RC4);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The inverse matrix of a negative-definite matrix is negative definite.
Screen output example:
A: Definite negative
-39.604949 +7.223354 -28.689030 -26.798513
+7.223354 -42.959966 -3.018440 -7.520833
-28.689030 -3.018440 -56.811738 +14.212596
-26.798513 -7.520833 +14.212596 -64.623348
invA:
-0.516185 -0.165366 +0.346903 +0.309595
-0.165366 -0.076970 +0.113222 +0.102434
+0.346903 +0.113222 -0.251945 -0.212443
+0.309595 +0.102434 -0.212443 -0.202503
Eigenvalues: eigs_mR(InvA,EValue);
-1.000
-0.022
-0.013
-0.012
Press return to continue
Press X return to stop