Linear Algebra and the C Language/a0cb


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA      RC5
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A          = rEsymmetric_mR(i_mR(RCA,RCA),999,+1.E-3);
double **EValue     =                i_mR(RCA,RCA); 

double **Exp_EValue = i_mR(RCA,RCA);
double **ExpA       = i_mR(RCA,RCA);  

double **V          = i_mR(RCA,RCA);
double **V_T        = i_mR(RCA,RCA);

double **T          = i_mR(RCA,RCA);

   clrscrn();     
   printf(" Copy/Paste into the octave window.       \n\n");
   p_Octave_mR(A,"A", P6);
   printf(" expm (A)\n\n\n");
 
      eigs_V_mR(A,V);
   transpose_mR(V,V_T);
    
/* EValue = V_T * A * V        */   
   mul_mR(V_T,A,T);
   mul_mR(T,V,EValue);  

   printf(" ExpA :");
   f_eigs_mR(exp,EValue, Exp_EValue);     
      mul_mR(V,Exp_EValue,T);
      mul_mR(T,V_T,ExpA);  
        p_mR(ExpA, S11,P6, C6);
       
   f_mR(A);
   f_mR(EValue);   
       
   f_mR(Exp_EValue);
   f_mR(ExpA); 
      
   f_mR(V);
   f_mR(V_T);

   f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun();
    
} while(stop_w());

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


Screen output example:

                                                                                       
 Copy/Paste into the octave window.       

 A=[
+1.353880,+0.768653,-0.387856,+0.877190,+0.845749;
+0.768653,+1.598690,-0.260210,+0.698741,-0.502396;
-0.387856,-0.260210,+1.984934,-0.726449,-0.703080;
+0.877190,+0.698741,-0.726449,+1.824694,+0.248152;
+0.845749,-0.502396,-0.703080,+0.248152,+3.560136]

 expm (A)


 ExpA :
 +15.309251   +6.738864  -12.239002  +13.347924  +20.093327 
  +6.738864   +9.968287   -4.782213   +8.330819   -1.171490 
 -12.239002   -4.782213  +17.167652  -12.770771  -20.930261 
 +13.347924   +8.330819  -12.770771  +16.694582  +14.541423 
 +20.093327   -1.171490  -20.930261  +14.541423  +54.197513 


 Press   return to continue
 Press X return to stop