Linear Algebra and the C Language/a0cx


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */     
#define RCA          RC4  
/* ------------------------------------ */       
/* ------------------------------------ */
int main(void)
{                          
double a[RCA*RCA] ={   
+0.729876318493, +0.169778846788, -0.191923913761, -0.362625471673, 
+0.169778846788, +0.893290152659, +0.120628523081, +0.227918315245, 
-0.191923913761, +0.120628523081, +0.863637321734, -0.257646791146, 
-0.362625471673, +0.227918315245, -0.257646791146, +0.513196207114                             
};

double v[RCA*RCA] ={
+0.532141930309, -0.579194958348, -0.801954709350, +0.519734241230, 
+0.846655163574, +0.000000000000, +0.000000000000, -0.326664732319, 
+0.000000000000, +0.815189057964, +0.000000000000, +0.369273175665, 
+0.000000000000, +0.000000000000, +0.597384837564, +0.697713259790      
};     
                       
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 =              i_mR(RCA,RCA);

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

  clrscrn(); 
  printf(" A :");
  p_mR(A, S8,P6, C4);     

  printf(" V :");
  p_mR(V, S9,P6, C4); 
 
  printf(" EValue = invV * A * V");
  mul_mR(invV,A,T);
  mul_mR(T,V,EValue);
  p_mR(EValue, S9,P6, C4); 
  stop();
  
  clrscrn();
  printf(" A :");
  p_mR(A, S8,P6, C4);
             
  printf(" A = V * EValue * invV        (Just verify the computation)");
  mul_mR(V,EValue,T);
  mul_mR(T,invV,A); 
  p_mR(A, S8,P6, C4);
  stop();
  
  clrscrn();
  printf(" V1        V2        V3        V4 :");
  p_mR(V, S9,P6, C4); 
   
  printf(" EValue1   EValue2   EValue3   EValue4 ");
  p_mR(EValue, S9,P6, C4); 
  
  printf(" det(V)  = %.3e\n"
         " det(V) != 0.00 V1,V2,V3 and V4 are linearly independent\n\n",
         det_R(V));  
  stop();
  
  clrscrn();                    
  printf(" The matrix A projects the space in  the direction\n"
         " of the  eigenvector V4  on a hyperplan determined\n"
         " by the eigenvector V1,V2 and V3 if :\n\n"
         " The eigenvector V1 has its eigenvalue equal to  one and   \n"
         " The eigenvector V2 has its eigenvalue equal to  one and   \n"
         " The eigenvector V3 has its eigenvalue equal to  one and   \n"
         " The eigenvector V4 has its eigenvalue equal to zero and \n\n"
         " If The vectors V1,V2,V3 and V4 are linearly independent \n\n");                   
  stop();  
  
  f_mR(A);
  f_mR(V);  
  f_mR(invV);  
  f_mR(T);  
  f_mR(EValue);

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


Screen output example:

                                                                                       
 A :
+0.729876 +0.169779 -0.191924 -0.362625 
+0.169779 +0.893290 +0.120629 +0.227918 
-0.191924 +0.120629 +0.863637 -0.257647 
-0.362625 +0.227918 -0.257647 +0.513196 

 V :
+0.532142 -0.579195 -0.801955 +0.519734 
+0.846655 +0.000000 +0.000000 -0.326665 
+0.000000 +0.815189 +0.000000 +0.369273 
+0.000000 +0.000000 +0.597385 +0.697713 

 EValue = invV * A * V
+1.000000 +0.000000 +0.000000 +0.000000 
-0.000000 +1.000000 +0.000000 -0.000000 
+0.000000 +0.000000 +1.000000 +0.000000 
-0.000000 -0.000000 -0.000000 +0.000000 

 Press return to continue. 


 A :
+0.729876 +0.169779 -0.191924 -0.362625 
+0.169779 +0.893290 +0.120629 +0.227918 
-0.191924 +0.120629 +0.863637 -0.257647 
-0.362625 +0.227918 -0.257647 +0.513196 

 A = V * EValue * invV        (Just verify the computation)
+0.729876 +0.169779 -0.191924 -0.362625 
+0.169779 +0.893290 +0.120629 +0.227918 
-0.191924 +0.120629 +0.863637 -0.257647 
-0.362625 +0.227918 -0.257647 +0.513196 

 Press return to continue. 


 V1        V2        V3        V4 :
+0.532142 -0.579195 -0.801955 +0.519734 
+0.846655 +0.000000 +0.000000 -0.326665 
+0.000000 +0.815189 +0.000000 +0.369273 
+0.000000 +0.000000 +0.597385 +0.697713 

 EValue1   EValue2   EValue3   EValue4 
+1.000000 +0.000000 +0.000000 +0.000000 
-0.000000 +1.000000 +0.000000 -0.000000 
+0.000000 +0.000000 +1.000000 +0.000000 
-0.000000 -0.000000 -0.000000 +0.000000 

 det(V)  = -7.933e-01
 det(V) != 0.00 V1,V2,V3 and V4 are linearly independent

 Press return to continue. 


 The matrix A projects the space in  the direction
 of the  eigenvector V4  on a hyperplan determined
 by the eigenvector V1,V2 and V3 if :

 The eigenvector V1 has its eigenvalue equal to  one and   
 The eigenvector V2 has its eigenvalue equal to  one and   
 The eigenvector V3 has its eigenvalue equal to  one and   
 The eigenvector V4 has its eigenvalue equal to zero and 

 If The vectors V1,V2,V3 and V4 are linearly independent 

 Press return to continue.