411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0ic
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 : c00d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double s = rp_I(7)+2;
double **A = rdefinite_positive_mR( i_mR(r, r), 99);
double **sA = smul_mR(s,A, i_mR(r, r));
double **EValue = eigs_mR(sA, i_mR(r,C1));
clrscrn();
printf(" If A is positive-definite and if s is a strictly positive \n"
" real number, then s*A is positive definite.\n\n"
" A:");
p_mR(A, S6,P0,C6);
printf(" %+.0f A: s > 0",s);
p_mR(sA, S6,P0,C6);
printf(" Eigen Value of: %+.0f A",s);
p_mR(EValue, S12,P3,C1);
f_mR(A);
f_mR(sA);
f_mR(EValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(RC4);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
If A is positive-definite and if s is a strictly positive real number, then s*A is positive definite.
Screen output example:
If A is positive-definite and if s is a strictly positive
real number, then s*A is positive definite.
A:
+22182 +13291 +1009 -10981
+13291 +10966 +1241 -4770
+1009 +1241 +17499 +210
-10981 -4770 +210 +21786
+6 A: s > 0
+133092 +79746 +6054 -65886
+79746 +65796 +7446 -28620
+6054 +7446 +104994 +1260
-65886 -28620 +1260 +130716
Eigen Value of: +6 A
+234869.870
+106607.570
+82018.764
+11101.796
Press return to continue
Press X return to stop