411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0ib
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__NOTOC__
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rdefinite_positive_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(" The inverse matrix of a positive-definite matrix\n"
" is positive-definite. (The eigen values are positive)\n\n"
" A:");
p_mR(A, S6,P0,C6);
printf(" invA:");
pE_mR(invA, S12,P6,C6);
printf(" Eigen Value: eigs_mR(InvA,EValue);");
pE_mR(EValue, S12,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 positive-definite matrix is positive-definite.
Screen output example:
The inverse matrix of a positive-definite matrix
is positive-definite. (The eigen values are positive)
A:
+7268 -7704 -6286 -3796
-7704 +18190 +5467 +9657
-6286 +5467 +10822 -6507
-3796 +9657 -6507 +24006
invA:
+1.345606e-03 -6.675553e-05 +1.146219e-03 +5.503218e-04
-6.675553e-05 +1.443631e-04 -1.827543e-04 -1.181663e-04
+1.146219e-03 -1.827543e-04 +1.199131e-03 +5.797988e-04
+5.503218e-04 -1.181663e-04 +5.797988e-04 +3.333710e-04
Eigen Value: eigs_mR(InvA,EValue);
+2.707e-03
+2.405e-04
+4.488e-05
+2.987e-05
Press return to continue
Press X return to stop