Linear Algebra and the C Language/a06u


Install and compile this file in your working directory.

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

double s = r_I(9);

int    r = rp_I(A[C_SIZE][C0]-C1);

  clrscrn();
  printf(" A:");
  p_mR(A,S3,P0,C6);
  printf(" The row[%d] of A is muliply by %+.0f\n",r,s);
  printf(" B:");
  p_mR(mulR_mR(c_mR(A,B),s,r),S3,P0,C6);

  printf("  If B is the matrix that  results when \n");
  printf("  a single row of A is muliplied by  \n");
  printf("  a scalar s, then det(B) = s det(A)\n\n");
  printf("    det_R(B) = %+.0f\n",  det_R(B));
  printf(" %+.0f det_R(A) = %+.0f\n",s,s*det_R(A));
  printf("    det_R(A) = %+.0f\n",det_R(A));

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

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

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


Screen output example:

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

 The row[4] of A is muliply by +8
 B:
 -6  +2  +2  +5 
 -8  -9  +4  +2 
 +7  -1  -6  +8 
+32  +8 +40 -72 

  If B is the matrix that  results when 
  a single row of A is muliplied by  
  a scalar s, then det(B) = s det(A)

    det_R(B) = -36168
 +8 det_R(A) = -36168
    det_R(A) = -4521

 Press   return to continue
 Press X return to stop