Linear Algebra and the C Language/a0i8


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(" A:");
  p_mR(A, S12,P6,C6);
  
  printf(" EigenValue: eigs_mR(A,EValue);");
  p_mR(EValue, S9,P3,C1);
  
  printf(" invA:");
  p_mR(invA, S12,P6,C6);

  f_mR(A);
  f_mR(invA);
  f_mR(EValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(RC3)+RC2);

} while(stop_w());

  return 0;
}

/* ------------------------------------ */
/* ------------------------------------ */
The eigenvalues ​​of a positive-definite matrix are positive. The matrix is ​​invertible.

Screen output example:

                                                                                       
 A:
  +47.793387   -23.274989    +0.205467   +18.540606 
  -23.274989   +64.709717    +2.779164   +15.073021 
   +0.205467    +2.779164   +28.483721   -29.186795 
  +18.540606   +15.073021   -29.186795   +57.013174 

 EigenValue: eigs_mR(A,EValue);
  +83.000 
  +81.000 
  +32.000 
   +2.000 

 invA:
   +0.094368    +0.064046    -0.117211    -0.107624 
   +0.064046    +0.062482    -0.094286    -0.085614 
   -0.117211    -0.094286    +0.230848    +0.181222 
   -0.107624    -0.085614    +0.181222    +0.167947 


 Press   return to continue
 Press X return to stop