Linear Algebra and the C Language/a06p


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00a.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);

  clrscrn();

  printf(" A \n");
  p_mR(A,S3,P0,C6);

  printf(" B \n");
  p_mR(B,S3,P0,C6);

  printf(" det(A) * det(B) = %+.0f\n",det_R(A)*det_R(B));
  printf(" det(AB)         = %+.0f\n",det_R(mul_mR(A,B,AB)));

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

  srand(time(&t));
  
do
{
  fun(rp_I(RC4)+RC1);
  
} while(stop_w());

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


Screen output example:

 A 

 -3  +2  +4  +7  -9 
 -3  -5  +6  -3  +9 
 +6  +2  +7  -8  +1 
 +7  -6  -8  +2  +8 
 +5  +7  +1  -2  -5 

 B 

 -3  +6  -4  +4  -9 
 -8  +2  -9  +6  -4 
 +8  -3  -8  -3  -5 
 -8  -9  -8  +2  -5 
 +8  +3  -1  +8  +7 

 det(A) * det(B) = -4127287140
 det(AB)         = -4127287140

 Press   return to continue
 Press X return to stop