Linear Algebra and the C Language/a03i


Install and compile this file in your working directory.

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

  clrscrn();
  printf(" A : ");
  p_mR(A, S5,P0,C6);        
  printf(" B : ");
  p_mR(B, S5,P0,C6);        

  printf(" Trace(AB) = %+.0f   \n",
           trace_R(mul_mR(A,B,AB)));
      
  printf(" Trace(BA) = %+.0f \n\n",
           trace_R(mul_mR(B,A,BA)));

  f_mR(A);
  f_mR(B);
  f_mR(AB);
  f_mR(BA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do{ 
  fun(rp_I(RC4)+RC2);

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
trace_R(A*B) = trace_R(B*A):

Screen output example:

                                                                                       
 A : 
   -7    +2    -5 
   +9    +9    -4 
   -9    +1    +1 

 B : 
   -2    +4    -4 
   -8    -4    +8 
   -6    -9    +1 

 Trace(AB) = +109   
 Trace(BA) = +109 


 Press   return to continue
 Press X return to stop