Linear Algebra and the C Language/a0de


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00e.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double s = rp_I(9);

double **A                 = rsymmetric_mR(   i_mR(r, r),99.);
double **EigsValueA        =       eigs_mR(A, i_mR(r,C1)    );

double **ID                =   eye_mR(        i_mR(r, r));
double **sID               = smul_mR(s,    ID,i_mR(r, r));
double **Apls_sID          =  add_mR(A,   sID,i_mR(r, r));
double **EigsValueApls_sID = eigs_mR(Apls_sID,i_mR(r,C1));

double **M                 =   m1_mR(         i_mR(r,C1));
double **sM                = smul_mR(s,M,     i_mR(r,C1));

  clrscrn();

  printf(" A :");
  p_mR(A,S3,P0,C6);
       
  printf(" EigsValue A :");
  p_mR(EigsValueA,S13,P6,C1);   

  printf(" A + %.0f*ID :",s);
  p_mR(Apls_sID,S4,P0,C6);
       
  printf(" EigsValue A + %.0f*ID :",s);
  p_mR(EigsValueApls_sID,S13,P6,C1); 

  stop(); 
   
  clrscrn();

  printf(" EigsValue A :");
  p_mR(EigsValueA,S13,P6,C1);    

  printf(" EigsValue A + %.0f*ID :",s);
  p_mR(EigsValueApls_sID,S13,P6,C1);  
  
  printf(" EigsValue A + %.0f :",s);
  add_mR(EigsValueA,sM,M); 
  p_mR(M,S13,P6,C1);   
    
  f_mR(A);
  f_mR(EigsValueA);

  f_mR(ID);
  f_mR(sID);
  f_mR(Apls_sID);  
  f_mR(EigsValueApls_sID);
  
  f_mR(M);
  f_mR(sM);  
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
 fun(rp_I(R2)+R2);

} while(stop_w());

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


Screen output example:

                                                                                       
 A :
-48 -75 +93 
-75 +44 -85 
+93 -85  +5 

 EigsValue A :
  +173.810563 
  -118.971698 
   -53.838865 

 A + 9*ID :
 -39  -75  +93 
 -75  +53  -85 
 +93  -85  +14 

 EigsValue A + 9*ID :
  +182.810563 
  -109.971698 
   -44.838865 

 Press return to continue. 


 EigsValue A :
  +173.810563 
  -118.971698 
   -53.838865 

 EigsValue A + 9*ID :
  +182.810563 
  -109.971698 
   -44.838865 

 EigsValue A + 9 :
  +182.810563 
  -109.971698 
   -44.838865 


 Press   return to continue
 Press X return to stop