Linear Algebra and the C Language/a0dc


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00c.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A         = rsymmetric_mR(    i_mR(r,r),9);
double **EValue    =       eigs_mR(A,  i_mR(r,C1));
double **Inv       =      invgj_mR(A,  i_mR(r,r));
double **invEValue =       eigs_mR(Inv,i_mR(r,C1));

int    i = 0;
int    j = 0;

  clrscrn();

  printf(" A:");
  p_mR(A,S2,P0,C6);
  
  printf(" inv(A)");
  pE_mR(Inv,S12,P4,C5);
  stop();

  clrscrn();
  printf(" EValue of A:");
  p_mR(EValue,S13,P6,C1); 
    
  printf(" EValue of invA:");
  p_mR(invEValue,S13,P6,C1);  
  
  for(i=1,j=r; i<=r; i++,j--)
       
       printf(" EValue[%d]*invEValue[%d]: %.3f    \n",
           i,j,EValue[i][C1]*invEValue[j][C1]);      
           
  f_mR(invEValue);  
  f_mR(EValue);  
  f_mR(Inv);
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
do
{
  fun(rp_I(RC4)+C1);

} while(stop_w());


  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

                                                                                       
 A:
+3 +1 +4 
+1 +2 -3 
+4 -3 -9 

 inv(A)
 +2.1094e-01  +2.3437e-02  +8.5938e-02 
 +2.3437e-02  +3.3594e-01  -1.0156e-01 
 +8.5938e-02  -1.0156e-01  -3.9063e-02 

 Press return to continue. 


 EValue of A:
   -10.980902 
    +4.216155 
    +2.764747 

 EValue of invA:
    +0.361697 
    +0.237183 
    -0.091067 

 EValue[1]*invEValue[3]: 1.000    
 EValue[2]*invEValue[2]: 1.000    
 EValue[3]*invEValue[1]: 1.000    

 Press   return to continue
 Press X return to stop