Linear Algebra and the C Language/a071


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A  = i_mR(r,r);
double **b  = i_mR(r,C5);
double **Ab = i_Abr_Ac_bc_mR(r,   r,  C5);
/*            i_Abr_Ac_bc_mR(R_Ab,C_A,C_b)); */

 do
  {
   r_mR(A,999.);
   printf(".");
  }while(!det_R(A));

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

  printf("       b1       b2      ...      bn :\n");
  r_mR(b,999.);
  p_mR(b,S8,P0,C6);
  stop();
  
  clrscrn();  
  printf(" Ab :");
  c_A_b_Ab_mR(A,b,Ab);
  p_mR(Ab,S8,P0,C6);
  stop();

  clrscrn();
  printf(" Copy/Paste into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf("\n rref(Ab,.00000000001)\n\n");
  printf("  gj_TP_mR(Ab) :");
  gj_TP_mR(Ab);
  p_mR(Ab,S10,P4,C6);

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

  srand(time(&t));
do
{
  fun(rp_I(RC5)+R1);


} while(stop_w());

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


Screen output example:

 Ab :
    -618     +815     -877     -583     -162     +873 
    +913     +892     +184     +455     -171     -441 
    +149     -196     +849     -763      +41     +800 
    -114     +873     +394     +984      -28     -609 

    +305      -37     -199 
    +204     +304     +241 
    +622     -389     +816 
    +453     -794     -568 

 Press return to continue. 


 Copy/Paste into the octave window.

 Ab=[
-618,+815,-877,-583,-162,+873,+305,-37,-199;
+913,+892,+184,+455,-171,-441,+204,+304,+241;
+149,-196,+849,-763,+41,+800,+622,-389,+816;
-114,+873,+394,+984,-28,-609,+453,-794,-568]


 rref(Ab,.00000000001)

  gj_TP_mR(Ab) :
   +1.0000    +0.0000    +0.0000    +0.0000    -0.0919    -0.3192 
   +0.0000    +1.0000    +0.0000    +0.0000    -0.1423    +0.3042 
   +0.0000    +0.0000    +1.0000    +0.0000    +0.0808    +0.1739 
   +0.0000    +0.0000    +0.0000    +1.0000    +0.0548    -0.9954 

   -0.2980    +0.8572    +0.5175 
   +0.5759    -0.3179    +0.0069 
   +0.6187    -0.7828    +0.2953 
   -0.3329    -0.1121    -0.6417 


 Press   return to continue
 Press X return to stop