Linear Algebra and the C Language/a0p4


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */     
#define RCA          RC3  
/* ------------------------------------ */       
/* ------------------------------------ */
int main(void)
{                          
double NVN[RCA*RCA] ={   
+0.784464540553, -0.408248290464, -0.557086014531, 
+0.588348405415, -0.408248290464, -0.742781352708, 
-0.196116135138, +0.816496580928, +0.371390676354  
};
 
double E[RCA*RCA] ={   
+1, 0, +0, 
+0, 1, +0, 
+0, 0, +0    
};
                       
double **Nvn    =  ca_A_mR(NVN,        i_mR(RCA,RCA));
double **invNvn = invgj_mR(Nvn,        i_mR(RCA,RCA));

double **EValue =  ca_A_mR(E,          i_mR(RCA,RCA));

double **T      =   mul_mR(Nvn,EValue, i_mR(RCA,RCA));
double **A      =   mul_mR(T,  invNvn, i_mR(RCA,RCA));

  clrscrn(); 
  printf(" Nv1,Nv2: The normalized plan vectors\n" 
         "     Nv3: The normalized projector vector\n\n");
  
  printf(" Nvn:  v1        v2        v3");
  p_mR(Nvn, S8,P6, C3);     

  printf(" EValue:     E1              E2              E3");
  p_mR(EValue, S9,P12, C4); 
 
  printf(" Copy this code into the files c00c.c and c00d.c\n\n"
         " A = Nvn EValue invNvn");
  P_mR(A, S8,P12, C3);
  stop();
  
  f_mR(A);
  f_mR(Nvn);
  f_mR(invNvn);
  f_mR(EValue);
  f_mR(T);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
 You calculate the matrix A that projects the plane in the direction of the  eigenvector (Nv3)  on a plan  determined by the eigenvectors (Nv1,Nv2). Next you must copy this matrix into the files c00c.c and c00d.c

Screen output example:

                                                                                       
 Nv1,Nv2: The normalized plan vectors
     Nv3: The normalized projector vector

 Nvn:  v1        v2        v3
+0.784465 -0.408248 -0.557086 
+0.588348 -0.408248 -0.742781 
-0.196116 +0.816497 +0.371391 

 EValue:     E1              E2              E3
+1.000000000000 +0.000000000000 +0.000000000000 
+0.000000000000 +1.000000000000 +0.000000000000 
+0.000000000000 +0.000000000000 +0.000000000000 

 Copy this code into the files c00c.c and c00d.c

 A = Nvn EValue invNvn
+2.363636363638, -1.909090909092, -0.272727272727, 
+1.818181818184, -1.545454545456, -0.363636363636, 
-0.909090909092, +1.272727272728, +1.181818181818  

 Press return to continue.