Linear Algebra and the C Language/a0ip


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RA R3
#define   CA C3
#define   Cb C5
/* ------------------------------------ */
int main(void)
{
double at[RA*CA]={
     +10,     -150,     -148, 
    +207,     -215,     +997, 
    -858,     +803,     +289  
};

double bt[RA*Cb]={
    +437,     -146,     -175,     -954,     -432, 
    -233,     +243,     +772,     +920,      -98, 
    +444,     -886,     -604,      -15,     +946  
};

/* --------- Copy "at" into A ------- */
double **A  = ca_A_mR(at, i_mR(RA,CA));

/* --------- Copy "bt" into b ------- */
double **b  = ca_A_mR(bt, i_mR(RA,Cb));

/* --------- Initialize Ab  ----------- */
double **Ab = i_Abr_Ac_bc_mR(RA,CA,Cb);

/* ------- Copy A and b into Ab ----- */
  c_A_b_Ab_mR(A,b,Ab);
/* ------------------------------------ */
  
  clrscrn();
  printf(" A :");
  p_mR(A, S8,P0,C6);

  printf("     b1       b2           ...           bn:");
  p_mR(b, S8,P0,C6);

  printf(" Ab:");
  p_mR(Ab, S8,P0,C8);
  stop();

  clrscrn();
  printf(" Copy/Paste into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf(" rref(Ab,.00000000001)\n\n\n\n");
  
  printf("  gj_TP_mR(Ab):");
  gj_TP_mR(Ab);
  p_mR(Ab, S8,P4,C8);
  stop();
  
  f_mR(Ab);
  f_mR(b);
  f_mR(A);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 A :
     +10     -150     -148 
    +207     -215     +997 
    -858     +803     +289 

     b1       b2           ...           bn:
    +437     -146     -175     -954     -432 
    -233     +243     +772     +920      -98 
    +444     -886     -604      -15     +946 

 Ab:
     +10     -150     -148     +437     -146     -175     -954     -432 
    +207     -215     +997     -233     +243     +772     +920      -98 
    -858     +803     +289     +444     -886     -604      -15     +946 

 Press return to continue. 


 Copy/Paste into the octave window.

 Ab=[
+10,-150,-148,+437,-146,-175,-954,-432;
+207,-215,+997,-233,+243,+772,+920,-98;
-858,+803,+289,+444,-886,-604,-15,+946]

 rref(Ab,.00000000001)



  gj_TP_mR(Ab):
 +1.0000  +0.0000  -0.0000  -3.3492  +2.0425  +1.5396  +5.7575  +1.5874 
 -0.0000  +1.0000  -0.0000  -2.9619  +1.0616  +0.6767  +5.7825  +2.8101 
 +0.0000  +0.0000  +1.0000  -0.1771  +0.0486  +0.6006  +0.9744  +0.1781 

 Press return to continue.