Linear Algebra and the C Language/a0cz


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */     
#define RCA          RC6  
/* ------------------------------------ */       
/* ------------------------------------ */
int main(void)
{                          
double a[RCA*RCA] ={   
+0.567743563267, +0.304424089190, -0.059677700710, -0.203424101776, +0.267148131435, -0.190855616323, 
+0.304424089190, +0.785604057676, +0.042029055301, +0.143264950247, -0.188143702858, +0.134413376479, 
-0.059677700710, +0.042029055301, +0.991760844584, -0.028084908937, +0.036882704058, -0.026349692872, 
-0.203424101776, +0.143264950247, -0.028084908937, +0.904266630484, +0.125722520384, -0.089818517482, 
+0.267148131435, -0.188143702858, +0.036882704058, +0.125722520384, +0.834894016457, +0.117954799378, 
-0.190855616323, +0.134413376479, -0.026349692872, -0.089818517482, +0.117954799378, +0.915730887532 
};

double v[RCA*RCA] ={
+0.575801565025, -0.136763612579, -0.425812987594, +0.525729633538, -0.403913441448, +0.657462118097,
+0.817589479944, +0.000000000000, +0.000000000000, +0.000000000000, +0.000000000000, -0.463029094469, 
+0.000000000000, +0.990603712023, +0.000000000000, +0.000000000000, +0.000000000000, +0.090769793525,
+0.000000000000, +0.000000000000, +0.904811195552, +0.000000000000, +0.000000000000, +0.309408095427, 
+0.000000000000, +0.000000000000, +0.000000000000, +0.850651722164, +0.000000000000, -0.406332356012, 
+0.000000000000, +0.000000000000, +0.000000000000, +0.000000000000, +0.914797208029, +0.290291426791  
};      
                       
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, C6);     

  printf(" V :");
  p_mR(V, S9,P6, C6); 
 
  printf(" EValue = invV * A * V");
  mul_mR(invV,A,T);
  mul_mR(T,V,EValue);
  p_mR(EValue, S9,P6, C6); 
  stop();
  
  clrscrn();
  printf(" A :");
  p_mR(A, S8,P6, C6);
             
  printf(" A = V * EValue * invV        (Just verify the computation)");
  mul_mR(V,EValue,T);
  mul_mR(T,invV,A); 
  p_mR(A, S8,P6, C6);
  stop();
  
  clrscrn();
  printf(" V1        V2        V3        V4        V5        V6 :");
  p_mR(V, S9,P6, C6); 
   
  printf(" EValue1   EValue2   EValue3   EValue4   EValue5   EValue6 ");
  p_mR(EValue, S9,P6, C6); 
  
  printf(" det(V)  = %.3e\n"
         " det(V) != 0.00 V1,V2,V3,V4,V5 and V6 are linearly independent\n\n",
         det_R(V));  
  stop();
  
  clrscrn();                    
  printf(" The matrix A projects the space in  the direction\n"
         " of the  eigenvector V6  on a hyperplan determined\n"
         " by the eigenvector V1,V2,V3,V4 and V5 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  one and   \n"
         " The eigenvector V5 has its eigenvalue equal to  one and   \n"
         " The eigenvector V6 has its eigenvalue equal to zero and \n\n"
         " If The vectors V1,V2,V3,V4,V5 and V6 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.567744 +0.304424 -0.059678 -0.203424 +0.267148 -0.190856 
+0.304424 +0.785604 +0.042029 +0.143265 -0.188144 +0.134413 
-0.059678 +0.042029 +0.991761 -0.028085 +0.036883 -0.026350 
-0.203424 +0.143265 -0.028085 +0.904267 +0.125723 -0.089819 
+0.267148 -0.188144 +0.036883 +0.125723 +0.834894 +0.117955 
-0.190856 +0.134413 -0.026350 -0.089819 +0.117955 +0.915731 

 V :
+0.575802 -0.136764 -0.425813 +0.525730 -0.403913 +0.657462 
+0.817589 +0.000000 +0.000000 +0.000000 +0.000000 -0.463029 
+0.000000 +0.990604 +0.000000 +0.000000 +0.000000 +0.090770 
+0.000000 +0.000000 +0.904811 +0.000000 +0.000000 +0.309408 
+0.000000 +0.000000 +0.000000 +0.850652 +0.000000 -0.406332 
+0.000000 +0.000000 +0.000000 +0.000000 +0.914797 +0.290291 

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

 Press return to continue. 


 A :
+0.567744 +0.304424 -0.059678 -0.203424 +0.267148 -0.190856 
+0.304424 +0.785604 +0.042029 +0.143265 -0.188144 +0.134413 
-0.059678 +0.042029 +0.991761 -0.028085 +0.036883 -0.026350 
-0.203424 +0.143265 -0.028085 +0.904267 +0.125723 -0.089819 
+0.267148 -0.188144 +0.036883 +0.125723 +0.834894 +0.117955 
-0.190856 +0.134413 -0.026350 -0.089819 +0.117955 +0.915731 

 A = V * EValue * invV        (Just verify the computation)
+0.567744 +0.304424 -0.059678 -0.203424 +0.267148 -0.190856 
+0.304424 +0.785604 +0.042029 +0.143265 -0.188144 +0.134413 
-0.059678 +0.042029 +0.991761 -0.028085 +0.036883 -0.026350 
-0.203424 +0.143265 -0.028085 +0.904267 +0.125723 -0.089819 
+0.267148 -0.188144 +0.036883 +0.125723 +0.834894 +0.117955 
-0.190856 +0.134413 -0.026350 -0.089819 +0.117955 +0.915731 

 Press return to continue. 


 V1        V2        V3        V4        V5        V6 :
+0.575802 -0.136764 -0.425813 +0.525730 -0.403913 +0.657462 
+0.817589 +0.000000 +0.000000 +0.000000 +0.000000 -0.463029 
+0.000000 +0.990604 +0.000000 +0.000000 +0.000000 +0.090770 
+0.000000 +0.000000 +0.904811 +0.000000 +0.000000 +0.309408 
+0.000000 +0.000000 +0.000000 +0.850652 +0.000000 -0.406332 
+0.000000 +0.000000 +0.000000 +0.000000 +0.914797 +0.290291 

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

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

 Press return to continue. 


 The matrix A projects the space in  the direction
 of the  eigenvector V6  on a hyperplan determined
 by the eigenvector V1,V2,V3,V4 and V5 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  one and   
 The eigenvector V5 has its eigenvalue equal to  one and   
 The eigenvector V6 has its eigenvalue equal to zero and 

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

 Press return to continue.