Linear Algebra and the C Language/a083


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00e.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **Ab = r_singular_Ab_mR(i_Abr_Ac_bc_mR(r,r,C1),999);
double **A  = c_Ab_A_mR(Ab,i_mR(r,r));
double **b  = c_Ab_b_mR(Ab,i_mR(r,C1));


  clrscrn();
  printf(" A :");
  p_mR(A,S8,P0,C7);
  printf(" b :");
  
  r_mR(b,999.);                        /* I change the value of b */
  
  p_mR(b,S8,P0,C7); 
  printf(" Ab :");
  p_mR(c_A_b_Ab_mR(A,b,Ab),S8,P0,C7);
  stop();

  clrscrn();
  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mR(Ab,"Ab",P0);
  printf("\n rref(Ab,.00000000001)\n\n");
  stop();

  clrscrn();
  printf(" gj_PP_mR(Ab,YES) :");
  gj_PP_mR(Ab,YES);
  p_mR(Ab,S10,P4,C7);
  
  is_system_consistent_mR(Ab);

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

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


} while(stop_w());

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


Screen output example:

 A :
    -356      +70     +237     +388     -732     +792 
    -356      +70     +237     +388     -732     +792 
    -696     +369     -409     -628     +429     -213 
    -263     +664     +448     +637     -941     -675 
    -226     -469      -39     -692     +713     -811 
    -263     +664     +448     +637     -941     -675 

 b :
    +763 
    -339 
     -12 
    +686 
     -70 
    -303 

 Ab :
    -356      +70     +237     +388     -732     +792     +763 
    -356      +70     +237     +388     -732     +792     -339 
    -696     +369     -409     -628     +429     -213      -12 
    -263     +664     +448     +637     -941     -675     +686 
    -226     -469      -39     -692     +713     -811      -70 
    -263     +664     +448     +637     -941     -675     -303 

 Press return to continue. 


 Copy/Past into the octave window.

 Ab=[
-356,+70,+237,+388,-732,+792,+763;
-356,+70,+237,+388,-732,+792,-339;
-696,+369,-409,-628,+429,-213,-12;
-263,+664,+448,+637,-941,-675,+686;
-226,-469,-39,-692,+713,-811,-70;
-263,+664,+448,+637,-941,-675,-303]


 rref(Ab,.00000000001)

 Press return to continue. 


 gj_PP_mR(Ab,YES) :
   +1.0000    +0.0000    +0.0000    +0.0000    +0.6347    -1.6038    -1.1294 
   +0.0000    +1.0000    +0.0000    +0.0000    +0.1060    -2.2264    -0.4195 
   +0.0000    +0.0000    +1.0000    +0.0000    -0.0250    -4.0278    +0.4538 
   +0.0000    +0.0000    +0.0000    +1.0000    -1.3081    +3.4317    +0.7287 
   +0.0000    +0.0000    +0.0000    +0.0000    +0.0000    +0.0000 -1102.0000 
   +0.0000    +0.0000    +0.0000    +0.0000    +0.0000    +0.0000  -989.0000 

 This(ese) row(s) are incompatible.
 row 5;   row 6;  
 The system is inconsistent. 
 I prefer to close the program.
 Press return to continue.