Linear Algebra and the C Language/a0d3


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:  c00b.c                    */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA C3
/* ------------------------------------ */
int main(void)
{
double a[RCA*RCA]={
+9,+9,+8,
+9,+6,+2,
+8,+2,+3
};

double **A        =       ca_A_mR(a,          i_mR(RCA,RCA));
double **EVector  =     eigs_V_mR(A,          i_mR(RCA,RCA));
double **EVectorT =  transpose_mR(EVector,    i_mR(RCA,RCA)); 
double **T1       =        mul_mR(EVectorT,A, i_mR(RCA,RCA));        
double **EValue   =        mul_mR(T1,EVector, i_mR(RCA,RCA));

  clrscrn();
  printf(" Copy/Paste into the octave windows \n");
  p_Octave_mR(A,"a",P0);
  printf(" [V, E] = eigs (a,%d) \n\n",RCA);
 
  printf(" EVector:");
  p_mR(EVector,S10,P4,C6);

  printf(" EValue: EVectorT A EVector");   
  p_mR(EValue,S10,P4,C6);  
  stop();
   
  f_mR(A);
  
  f_mR(EVector);
  f_mR(EVectorT);
  
  f_mR(EValue);  
     
  f_mR(T1);
  
    return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 Copy/Paste into the octave windows 
 a=[
+9,+9,+8;
+9,+6,+2;
+8,+2,+3]

 [V, E] = eigs (a,3) 

 EVector:
   +0.7384    -0.6622    +0.1276 
   +0.5346    +0.4594    -0.7094 
   +0.4111    +0.5920    +0.6932 

 EValue: EVectorT A EVector
  +19.9697    -0.0000    +0.0000 
   +0.0000    -4.3960    +0.0000 
   +0.0000    -0.0000    +2.4263 

 Press return to continue.