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  =        i_mR(r,r);
double **T   =        i_mR(r,r);

  clrscrn();  
  printf(" Q :                an orthonormal matrix");
  p_mR(Q,S3,P3,C6);
  
  printf(" QT :");
  transpose_mR(Q,QT);
  p_mR(QT,S3,P3,C6);  
  stop();

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

  printf(" QT * Q :            (Q = inv(QT)");
  mul_mR(QT,Q,T);
  p_mR(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.103 -0.179 +0.288 -0.935 
+0.205 +0.567 +0.782 +0.155 
-0.923 +0.348 +0.022 -0.161 
+0.308 +0.725 -0.552 -0.275 

 QT :
+0.103 +0.205 -0.923 +0.308 
-0.179 +0.567 +0.348 +0.725 
+0.288 +0.782 +0.022 -0.552 
-0.935 +0.155 -0.161 -0.275 

 Press return to continue. 


 Q * QT :           (QT = inv(Q)
 +1  +0  +0  -0 
 +0  +1  -0  +0 
 +0  -0  +1  +0 
 -0  +0  +0  +1 

 QT * Q :            (Q = inv(QT)
 +1  +0  +0  +0 
 +0  +1  -0  -0 
 +0  -0  +1  -0 
 +0  -0  -0  +1 


 Press   return to continue
 Press X return to stop