Linear Algebra and the C Language/a0la


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00d1.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RC RC4
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **u      =   r_mR(     i_mR(RC,C1) ,9.);

double **Q      = r_Q_mR(     i_mR(RC,RC), 9);
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));
   
  f_mR(u); 
  f_mR(Qu);
  f_mR(Q);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

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

Screen output example:

                                                                                       
 Q:             an orthonormal matrix 
-0.64993 -0.08767 +0.34102 +0.67350 
+0.27854 -0.95034 +0.01384 +0.13808 
-0.64993 -0.29107 +0.06673 -0.69887 
-0.27854 -0.06663 -0.93758 +0.19726 

 u:
+8.00000 
+3.00000 
+1.00000 
+2.00000 

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

    8.832   = 8.832           

 
 Press   return to continue
 Press X return to stop