Linear Algebra and the C Language/a0d2


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A            = rsymmetric_mR(i_mR(r,r),9.);
double **EigsVector   =               i_mR(r,r);
double **EigsValue    =               i_mR(r,r);
double **T_EigsVector =               i_mR(r,r);

double **T1 =                         i_mR(r,r);

  clrscrn();
  printf(" Copy/Paste into the octave windows \n\n");
  p_Octave_mR(A,"a",P0);
  printf(" [V, E] = eigs (a,%d) \n\n",r);
  stop();

  clrscrn();   
  eigs_V_mR(A,EigsVector); 
  printf(" EignVector:");
  p_mR(EigsVector,S10,P4,C6);

  printf(" EigsValue : T_EigsVector * A * EigsVector");   
  transpose_mR(EigsVector,T_EigsVector);   
  mul_mR(T_EigsVector,A,T1);
  mul_mR(T1,EigsVector,EigsValue);
  p_mR(EigsValue,S10,P4,C6);  
   
  f_mR(A);
  
  f_mR(EigsVector);
  f_mR(T_EigsVector);
  
  f_mR(EigsValue);  
     
  f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
 fun(rp_I(R3)+R1);

} while(stop_w());

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


Screen output example:

                                                                                       
 Copy/Paste into the octave windows 

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

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

 Press return to continue. 


 EignVector:
   +0.8592    -0.0614    +0.4757    +0.1780 
   +0.3732    +0.5792    -0.3650    -0.6262 
   -0.3499    +0.4804    +0.7748    -0.2158 
   +0.0072    +0.6558    -0.2006    +0.7278 

 EigsValue : T_EigsVector * A * EigsVector
  -14.4730    +0.0000    -0.0000    +0.0000 
   +0.0000   +14.1827    +0.0000    +0.0000 
   -0.0000    +0.0000    +7.8487    -0.0000 
   +0.0000    +0.0000    -0.0000    -4.5584 


 Press   return to continue
 Press X return to stop