Linear Algebra and the C Language/a071


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define Cb C4
/* ------------------------------------ */
void fun(int r)
{
double **A  =        r_mR(     i_mR(r,r),999);
double **b  =        r_mR(     i_mR(r,Cb),999);
double **Ab = c_A_b_Ab_mR(A,b, i_Abr_Ac_bc_mR(r,r,Cb));

  clrscrn();
  printf(" A:");
  p_mR(A, S8,P0,C4);

  printf("       b1       b2      ...      bn:");
  p_mR(b, S8,P0,C4);
  stop();
  
  clrscrn();
  printf(" Copy/Paste into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf(" rref(Ab,.00000000001)\n\n");
  
  printf(" gj_TP_mR(Ab):");
  p_mR(gj_TP_mR(Ab), S10,P4,C4);

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

  srand(time(&t));
do
{
  fun(RC4);


} while(stop_w());

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

Screen output example:

 A:
     +64     +279     +379     -685 
    +690     -251     -783     -419 
    -916     -524     +731     +631 
    +796     +133     +162      -44 

       b1       b2      ...      bn:
    -826     +468     -599     +507 
    +386     +492     -347     +929 
    +383     +982     +136     +135 
    +282     +723     -710     -824 

 Press return to continue. 


 Copy/Paste into the octave window.

 Ab=[
+64,+279,+379,-685,-826,+468,-599,+507;
+690,-251,-783,-419,+386,+492,-347,+929;
-916,-524,+731,+631,+383,+982,+136,+135;
+796,+133,+162,-44,+282,+723,-710,-824]

 rref(Ab,.00000000001)

 gj_TP_mR(Ab):
   +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 

   +0.5792    +0.9838    -0.8085    -0.7737 
   -0.9303    -2.5060    +0.7376    -1.5837 
   -0.1202    +1.4694    -0.8441    -0.4480 
   +0.8145    -0.7990    +0.6323    -1.7053 


 Press   return to continue
 Press X return to stop