Linear Algebra and the C Language/a0ac


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00i.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **U             = r_mR(i_mR(r,r),9.);
double **Orth          =      i_mR(r,r);
double **Orth_Normal   =      i_mR(r,r);
double **Orth_Normal_T =      i_mR(r,r);

  clrscrn();
  printf(" U :");
  p_mR(U, S8,P4, C6); 

  printf(" Orth_Normal : orth_mR(U,Orth,YES);");
  orth_mR(U,Orth,YES);
  p_mR(Orth, S8,P4, C6);  
  stop();

  clrscrn();
  printf(" Orth_Normal :");
  p_mR(Orth, S8,P4, C6); 
  
  printf(" Orth_Normal_T : transpose_mR(Orth,Orth_Normal_T);");
  transpose_mR(Orth,Orth_Normal_T);
  p_mR(Orth_Normal_T, S8,P4, C6); 
    
  printf(" Orth_Normal_T Orth_Normal  :");
  mul_mR(Orth_Normal_T,Orth, U);
  p_mR(U, S8,P4, C6);  
    
  f_mR(U);
  f_mR(Orth);
  f_mR(Orth_Normal);  
  f_mR(Orth_Normal_T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(R2)+R2);
} while(stop_w());

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


Screen output example:

                                                                                       

 U :
 +8.0000  -3.0000  -1.0000  +1.0000 
 +8.0000  +7.0000  +1.0000  +5.0000 
 +1.0000  -3.0000  -6.0000  +9.0000 
 +6.0000  -6.0000  +9.0000  -2.0000 

 Orth_Normal : orth_mR(U,Orth,YES);
 +0.6228  -0.2625  -0.3959  -0.6217 
 +0.6228  +0.7242  +0.0386  +0.2935 
 +0.0778  -0.2918  -0.7000  +0.6471 
 +0.4671  -0.5669  +0.5930  +0.3297 

 Press return to continue. 


 Orth_Normal :
 +0.6228  -0.2625  -0.3959  -0.6217 
 +0.6228  +0.7242  +0.0386  +0.2935 
 +0.0778  -0.2918  -0.7000  +0.6471 
 +0.4671  -0.5669  +0.5930  +0.3297 

 Orth_Normal_T : transpose_mR(Orth,Orth_Normal_T);
 +0.6228  +0.6228  +0.0778  +0.4671 
 -0.2625  +0.7242  -0.2918  -0.5669 
 -0.3959  +0.0386  -0.7000  +0.5930 
 -0.6217  +0.2935  +0.6471  +0.3297 

 Orth_Normal_T Orth_Normal  :
 +1.0000  +0.0000  +0.0000  +0.0000 
 +0.0000  +1.0000  -0.0000  -0.0000 
 +0.0000  -0.0000  +1.0000  +0.0000 
 +0.0000  -0.0000  +0.0000  +1.0000 


 Press   return to continue
 Press X return to stop