Linear Algebra and the C Language/a0l7


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00b2.c                  */
/* ------------------------------------ */
#include "v_a.h" 
/* ------------------------------------ */
/* ------------------------------------ */
#define   RC RC3
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
	
double tx[RC*C1]={
 -7, 
 -6, 
 +8 
};

double tB[RC*RC]={
+0.4819, +0.4615, +0.7448, 
+0.6196, -0.7806, +0.0828, 
+0.6196, +0.4216, -0.6621 
};
	
double **B    =  ca_A_mR(tB,       i_mR(RC,RC));  
double **invB = invgj_mR(B,        i_mR(RC,RC));

double **x_S  =  ca_A_mR(tx,       i_mR(RC,C1));
double **x_B  =   mul_mR(invB,x_S, i_mR(RC,C1));
     
  clrscrn();
  printf(" B is the basis change matrix for the basis \"B\" \n\n"
         " B:             orthonormal matrix");
  p_mR(B, S10,P4,C7);
  
  printf("invB:              invB = transpose of B");
  p_mR(invB, S10,P4,C7);
  stop();  
    
  clrscrn();
  printf(" x_S: Standart basis");        
  p_mR(x_S, S10,P4,C6); 
  
  printf("  Compute x_S in the B basis:\n\n"
         " x_B         = invB x_S:");
  p_mR(x_B, S10,P4,C7);  
  stop();  

  f_mR(x_S);        
  f_mR(B);
  f_mR(invB);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 B is the basis change matrix for the basis "B" 

 B:             orthonormal matrix
   +0.4819    +0.4615    +0.7448 
   +0.6196    -0.7806    +0.0828 
   +0.6196    +0.4216    -0.6621 

invB:              invB = transpose of B
   +0.4819    +0.6195    +0.6196 
   +0.4615    -0.7805    +0.4216 
   +0.7449    +0.0828    -0.6621 

 Press return to continue. 


 x_S: Standart basis
   -7.0000 
   -6.0000 
   +8.0000 

  Compute x_S in the B basis:

 x_B         = invB x_S:
   -2.1340 
   +4.8250 
  -11.0074 

 Press return to continue.