Linear Algebra and the C Language/a0ic


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(" A:");
  p_mR(A, S12,P6,C6);
  
  printf(" %+.0f A:   s > 0",s);
  p_mR(sA, S12,P6,C6);
  
  printf(" EigenValue: eigs_mR(%+.0f A,EValue);",s);
  p_mR(EValue, S9,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:

                                                                                       
 A:
  +66.085953   +11.415062   -12.899895    -3.233224 
  +11.415062   +61.610737    -3.496973    -2.827082 
  -12.899895    -3.496973   +78.710281    -6.695413 
   -3.233224    -2.827082    -6.695413   +52.593030 

 +9 A:   s > 0
 +594.773574  +102.735560  -116.099056   -29.099020 
 +102.735560  +554.496632   -31.472754   -25.443737 
 -116.099056   -31.472754  +708.392527   -60.258716 
  -29.099020   -25.443737   -60.258716  +473.337267 

 EigenValue: eigs_mR(+9 A,EValue);
 +810.000 
 +621.000 
 +468.000 
 +432.000 


 Press   return to continue
 Press X return to stop