Linear Algebra and the C Language/a0bs


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = r_Q_mR(i_mR(r,r), 9);
double **B = r_Q_mR(i_mR(r,r), 9);
double **AB  =      i_mR(r,r);
double **ABT =      i_mR(r,r);
double **T   =      i_mR(r,r);

  clrscrn();
  printf(" A :                an orthonormal matrix ");
  p_mR(A,S3,P3,C6); 
  printf(" B :                an orthonormal matrix ");
  p_mR(B,S3,P3,C6);
  stop();

  clrscrn();
  printf("   A * B  = AB  :   AB is an orthonormal matrix");
  mul_mR(A,B,AB);
  p_mR(AB,S3,P3,C6);    

  printf(" AB * ABT = id :    inv(AB) = ABT ");
  transpose_mR(AB,ABT);
  mul_mR(AB,ABT,T);
  p_mR(T,S3,P3,C6);    
  
  f_mR(A);
  f_mR(B);
  f_mR(AB);
  f_mR(ABT);
  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:

                                                                                       
 A :                an orthonormal matrix 
-0.417 -0.093 -0.046 +0.001 +0.903 
-0.583 +0.307 -0.701 -0.003 -0.273 
-0.500 +0.497 +0.690 +0.073 -0.145 
-0.417 -0.638 +0.166 -0.574 -0.249 
-0.250 -0.492 +0.053 +0.816 -0.164 

 B :                an orthonormal matrix 
-0.204 -0.534 -0.606 +0.277 -0.479 
-0.306 +0.502 -0.445 +0.518 +0.433 
-0.919 -0.057 +0.368 -0.109 -0.074 
+0.102 +0.441 +0.330 +0.481 -0.675 
+0.102 -0.515 +0.436 +0.642 +0.350 

 Press return to continue. 


   A * B  = AB  :   AB is an orthonormal matrix
+0.248 -0.286 +0.671 +0.422 +0.478 
+0.640 +0.645 -0.161 -0.102 +0.370 
-0.692 +0.584 +0.297 -0.014 +0.304 
+0.044 -0.233 +0.300 -0.900 +0.211 
+0.219 +0.327 +0.588 -0.043 -0.705 

 AB * ABT = id :    inv(AB) = ABT 
+1.000 -0.000 -0.000 -0.000 -0.000 
-0.000 +1.000 +0.000 +0.000 +0.000 
-0.000 +0.000 +1.000 +0.000 +0.000 
-0.000 +0.000 +0.000 +1.000 +0.000 
-0.000 +0.000 +0.000 +0.000 +1.000 


 Press   return to continue
 Press X return to stop