Linear Algebra and the C Language/a0mb


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c04d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */     
#define RCA          RC4  
/* ------------------------------------ */       
/* ------------------------------------ */
int main(void)
{                          
double a[RCA*RCA]={
+9.825339522090, +7.309094034726, -3.954100051573, -1.198212136840, 
+7.309094034726, +5.437252879491, -2.941464672512, -0.891352931064, 
-3.954100051573, -2.941464672512, +1.591284167096, +0.482207323363, 
-1.198212136840, -0.891352931064, +0.482207323363, +0.146123431322     
};

double v[RCA*RCA]={
-0.760237560476, -0.596864313004, +0.373340433764, +0.121054375311, 
-0.565542575476, +0.802342191251, +0.000000000000, +0.000000000000, 
+0.305949262143, +0.000000000000, +0.927694411171, +0.000000000000, 
+0.092711897619, +0.000000000000, +0.000000000000, +0.992645877551     
};
                        
double **A      =  ca_A_mR(a, i_mR(RCA,RCA));
double **V      =  ca_A_mR(v, i_mR(RCA,RCA));
double **invV   = invgj_mR(V, i_mR(RCA,RCA));
double **EValue =  eigs_mR(A, i_mR(RCA, RCA));

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

  clrscrn(); 
  printf(" The eigenvectors associated with eigenvalues\n"
         " with multiple multiplicity are not unique.  \n"
         " There exist several set of unit vectors that\n"
         " correspond to the same eigenspace.      \n\n\n"
         
         " An eigenvector associated with an eigenvalue\n"
         " with single multiplicity  is unique, up to a\n"
         " change in the sign.                     \n\n\n");
       
  printf(" A:");
  p_mR(A, S9,P5, C4);     
  stop();
    
  clrscrn();  
  printf(" V:");
  p_mR(V, S9,P5, C4); 
 
  printf(" EValue = invV A V");
  mul_mR(invV,A,T);
  mul_mR(T,V,EValue);
  p_mR(clean_eye_mR(EValue), S9,P5, C4);  
         
  printf(" A = V EValue invV");
  mul_mR(V,EValue,T);
  mul_mR(T,invV,A); 
  p_mR(A, S9,P5, C4);     
  stop();
              
  f_mR(A);
  f_mR(V);  
  f_mR(invV);  
  f_mR(T);  
  f_mR(EValue);

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

Screen output example:

                                                                                       
 The eigenvectors associated with eigenvalues
 with multiple multiplicity are not unique.  
 There exist several set of unit vectors that
 correspond to the same eigenspace.      


 An eigenvector associated with an eigenvalue
 with single multiplicity  is unique, up to a
 change in the sign.                     


 A:
 +9.82534  +7.30909  -3.95410  -1.19821 
 +7.30909  +5.43725  -2.94146  -0.89135 
 -3.95410  -2.94146  +1.59128  +0.48221 
 -1.19821  -0.89135  +0.48221  +0.14612 

 Press return to continue. 


 V:
 -0.76024  -0.59686  +0.37334  +0.12105 
 -0.56554  +0.80234  +0.00000  +0.00000 
 +0.30595  +0.00000  +0.92769  +0.00000 
 +0.09271  +0.00000  +0.00000  +0.99265 

 EValue = invV A V
+17.00000  +0.00000  +0.00000  +0.00000 
 +0.00000  -0.00000  +0.00000  +0.00000 
 +0.00000  +0.00000  -0.00000  +0.00000 
 +0.00000  +0.00000  +0.00000  +0.00000 

 A = V EValue invV
 +9.82534  +7.30909  -3.95410  -1.19821 
 +7.30909  +5.43725  -2.94146  -0.89135 
 -3.95410  -2.94146  +1.59128  +0.48221 
 -1.19821  -0.89135  +0.48221  +0.14612 

 Press return to continue.