Linear Algebra and the C Language/a0br


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **Q   =       r_Q_mR(   i_mR(r,r), 9);
double **QT  = transpose_mR(Q, i_mR(r,r));
double **T   =                 i_mR(r,r);

  clrscrn();  
  printf(" Q :                An orthonormal matrix");
  p_mR(Q,S3,P3,C6);
  
  printf(" QT :               QT = inv(Q)          ");
  p_mR(QT,S3,P3,C6);  
  stop();

  clrscrn();
  printf(" Q QT:");
  p_mR(mul_mR(Q,QT,T),S3,P0,C6);    

  printf(" QT Q:");
  p_mR(mul_mR(QT,Q,T),S3,P0,C6);    
   
  f_mR(Q);
  f_mR(QT);
  f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(R3) + R2);

} while(stop_w());

  return 0;
}

/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 Q :                An orthonormal matrix
-0.557 -0.238 +0.796 
-0.743 -0.286 -0.605 
-0.371 +0.928 +0.017 

 QT :               QT = inv(Q)          
-0.557 -0.743 -0.371 
-0.238 -0.286 +0.928 
+0.796 -0.605 +0.017 

 Press return to continue. 


 Q QT:
 +1  +0  -0 
 +0  +1  -0 
 -0  -0  +1 

 QT Q:
 +1  -0  +0 
 -0  +1  +0 
 +0  +0  +1 


 Press   return to continue
 Press X return to stop