411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0i8
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 : c00a.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(A, i_mR(r,C1));
clrscrn();
printf(" The eigenvalues of a positive-definite matrix\n"
" are positive. The matrix is invertible.\n\n"
" A:");
p_mR(A, S12,P2,C6);
printf(" EigenValue: eigs_mR(A,EValue);");
p_mR(EValue, S12,P3,C1);
printf(" invA:");
pE_mR(invA, S12,P3,C6);
f_mR(A);
f_mR(invA);
f_mR(EValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC2)+RC2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The eigenvalues of a positive-definite matrix are positive. The matrix is invertible.
Screen output example:
The eigenvalues of a positive-definite matrix
are positive. The matrix is invertible.
A:
+9828.00 -2406.00 -1704.00
-2406.00 +7989.00 -4512.00
-1704.00 -4512.00 +3608.00
EigenValue: eigs_mR(A,EValue);
+11802.782
+9603.465
+18.753
invA:
+3.983e-03 +7.701e-03 +1.151e-02
+7.701e-03 +1.532e-02 +2.279e-02
+1.151e-02 +2.279e-02 +3.422e-02
Press return to continue
Press X return to stop