Linear Algebra and the C Language/a0n5


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:  c00e.c                    */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define ARRAY   A3
/* ------------------------------------ */
#define RC     RC3
/* ------------------------------------ */
void fun(void)
{
double **A         = rsymmetric_mR(        i_mR(RC,RC),999);
double **AEVect    =     eigs_V_mR(A,      i_mR(RC,RC));
double **InvAEVect =  transpose_mR(AEVect, i_mR(RC,RC));

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

double **b [ARRAY];
double **r [ARRAY];
double **br[ARRAY];

int i;

  for(i=A0; i<ARRAY; i++)
     {
      b[i]  = c_c_mR(   AEVect,i+C1, i_mR(RC,C1),C1);
      r[i]  = c_r_mR(InvAEVect,i+R1, i_mR(R1,RC),R1);
      
      br[i] = mul_mR(b[i],r[i],      i_mR(RC,RC));       
      }
      
  clrscrn();
  printf(" A:");
  p_mR(A, S10,P4,C6);

  printf(" AEVect:        Eingvectors of A");
  p_mR(AEVect, S10,P4,C6);

  transpose_mR(AEVect,InvAEVect);
  printf(" Inverse of AEVect = InvAEVect");
  p_mR(InvAEVect, S10,P4,C6);
  stop();

  clrscrn(); 
  mul_mR(br[0], br[1], T);  
  printf(" This simply materializes that our projectors\n"
         " bnrn are orthogonal to each other.    \n\n\n\n"
         " b1r1 * b2r2");
  p_mR(T, S10,P4,C6);
  
  mul_mR(br[0], br[2], T);  
  printf(" b1r1 * b3r3");
  p_mR(T, S10,P4,C6);
  
  mul_mR(br[1], br[2], T);  
  printf(" b2r2 * b3r3");
  p_mR(T, S10,P4,C6);
  
  f_mR(A);
  f_mR(AEVect);
  f_mR(InvAEVect);  

  f_mR(T);
  
  for(i=A0; i<ARRAY; i++)
     {
       f_mR( b[i]);
       f_mR( r[i]); 
       f_mR(br[i]);               
     }   
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
 fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
A property of spectral decomposition:

        b1r1 * b2r2 = 0
        b1r1 * b3r3 = 0
        b2r2 * b3r3 = 0
  
   This simply materializes that our projectors are orthogonal to each other.

  b: The columns of the eigenvectors of A
  r: The rows of eigenvectors of the inverse of A
 
  b1r1 is obtained by multiplying the first column of the eigenvector of A by the first row of the eigenvector of the inverse of A.

Screen output example:

                                                                                       
 A:
 +292.0000  +262.0000  -677.0000 
 +262.0000  -959.0000  -735.0000 
 -677.0000  -735.0000  -272.0000 

 AEVect:        Eingvectors of A
   +0.0995    +0.7319    +0.6741 
   +0.8154    +0.3283    -0.4768 
   +0.5703    -0.5971    +0.5641 

 Inverse of AEVect = InvAEVect
   +0.0995    +0.8154    +0.5703 
   +0.7319    +0.3283    -0.5971 
   +0.6741    -0.4768    +0.5641 

 Press return to continue. 


 This simply materializes that our projectors
 bnrn are orthogonal to each other.    



 b1r1 * b2r2
   +0.0000    +0.0000    -0.0000 
   +0.0000    +0.0000    -0.0000 
   +0.0000    +0.0000    -0.0000 

 b1r1 * b3r3
   -0.0000    +0.0000    -0.0000 
   -0.0000    +0.0000    -0.0000 
   -0.0000    +0.0000    -0.0000 

 b2r2 * b3r3
   +0.0000    -0.0000    +0.0000 
   +0.0000    -0.0000    +0.0000 
   -0.0000    +0.0000    -0.0000 


 Press   return to continue
 Press X return to stop