Linear Algebra and the C Language/a0ib


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(" A:");
  p_mR(A, S12,P6,C6);
  
  printf(" invA:");
  p_mR(invA, S12,P6,C6);
  
  printf(" EigenValue: 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 positive-definite matrix is ​​positive-definite.

Screen output example:

                                                                                       
 A:
  +13.713889    +6.490352    +5.952208   +19.853010 
   +6.490352   +79.316031   +11.338870    -7.410039 
   +5.952208   +11.338870   +72.497546    -7.361583 
  +19.853010    -7.410039    -7.361583   +72.472534 

 invA: 
   +0.149482    -0.014259    -0.014498    -0.043880 
   -0.014259    +0.014348    -0.000533    +0.005319 
   -0.014498    -0.000533    +0.015626    +0.005504 
   -0.043880    +0.005319    +0.005504    +0.026922 

 EigenValue: eigs_mR(InvA,EValue);
   +0.167 
   +0.016 
   +0.013 
   +0.011 


 Press   return to continue
 Press X return to stop