Linear Algebra and the C Language/a0lb


Install and compile this file in your working directory.

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

double tQ[RC*RC]={
+0.4819, +0.4615, +0.7448, 
+0.6196, -0.7806, +0.0828, 
+0.6196, +0.4216, -0.6621 
};

double **u      = ca_A_mR(tu,  i_mR(RC,C1));
double **Q      = ca_A_mR(tQ,  i_mR(RC,RC));               
double **Qu     =  mul_mR(Q,u, i_mR(RC,C1));

  clrscrn();
  printf(" Q:             an orthonormal matrix ");
  p_mR(Q, S3,P5,C6);
  
  printf(" u:");
  p_mR(u, S3,P5,C6);

  printf(" ||Q u||     = ||u|| "
         "                Orthonormal matrices preserve lengths:\n\n " 
         "   %.3f   = %.3f           \n\n ",  
          norm_R(Qu), norm_R(u));
  stop();
   
  f_mR(u); 
  f_mR(Q);
  f_mR(Qu);

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

Screen output example:

                                                                                       
 Q:             an Orthonormal matrix 
+0.48190 +0.46150 +0.74480 
+0.61960 -0.78060 +0.08280 
+0.61960 +0.42160 -0.66210 

 u:
-7.00000 
-6.00000 
+8.00000 

 ||Q u||     = ||u||                 Orthonormal matrices preserve lengths:

    12.207   = 12.207           

  Press return to continue.