Linear Algebra and the C Language/a0d5


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA        RC3
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A            = rsymmetric_mR(           i_mR(RCA,RCA),9.);

double **EigsVector   =     eigs_V_mR(A,         i_mR(RCA,RCA)); 
double **T_EigsVector =  transpose_mR(EigsVector,i_mR(RCA,RCA)); 

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

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

  clrscrn();
  printf(" Copy/Paste into the octave windows \n\n");
  p_Octave_mR(A,"a",P0);
  printf(" [V, E] = eigs (a,%d) \n\n",RCA);
   
  printf(" EigsVector:");  
  p_mR(EigsVector,S10,P4,C6);
     
  printf(" EigsValue = T_EigsVector * A * EigsVector"); 
  mul_mR(T_EigsVector,A,T);
  mul_mR(T,EigsVector,eigs_values);
  p_mR(eigs_values,S10,P4,C6);  
     
  f_mR(A);
  
  f_mR(EigsVector);
  f_mR(T_EigsVector);
  
  f_mR(eigs_values);
       
  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 windows 

 a=[
+3,+8,-3;
+8,-2,-2;
-3,-2,+7]

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

 EigsVector:
   +0.6407    -0.5943    +0.4861 
   +0.4646    +0.8041    +0.3708 
   -0.6113    -0.0117    +0.7913 

 EigsValue = T_EigsVector * A * EigsVector
  +11.6639    +0.0000    +0.0000 
   +0.0000    -7.8835    +0.0000 
   +0.0000    +0.0000    +4.2196 


 Press   return to continue
 Press X return to stop