Linear Algebra and the C Language/a09f


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RAb  R2
#define   CA   C6
#define   Cb   C1
/* ------------------------------------ */
# define FREEV C4
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ab[RAb*(CA+C1)]={
     -18, -549, -119, -715, -233, -640,   30,
    +152,  -42, -910, -730, +359, -799,  800  
};

double **Ab      = ca_A_mR(ab, i_Abr_Ac_bc_mR(RAb, CA, Cb));
double **Ab_free =             i_Abr_Ac_bc_mR(CA,  CA, Cb + FREEV);
double **b_free  =                       i_mR(CA,      Cb + FREEV); 
 
  clrscrn();
  printf(" Ab:");
  p_mR(Ab, S8,P3,C11);
  
  printf(" Ab:  gj_PP_mR(Ab,NO):");
  gj_PP_mR(Ab,NO);
  p_mR(Ab, S8,P3,C11);

  put_zeroR_mR(Ab,Ab_free);  
  printf("\n\n Ab_free: put_zeroR_mR(Ab,Ab_free);");  
  p_mR(Ab_free, S6,P3,C11);  
  stop();
  
  clrscrn();  
  put_freeV_mR(Ab_free);
  printf(" Ab_free: put_freeV_mR(Ab_free);");  
  p_mR(Ab_free, S6,P3,C11);  

  printf("\n\n Ab_free: gj_PP_mR(Ab_free,YES);");
  gj_PP_mR(Ab_free,YES); 
  p_mR(Ab_free, S6,P3,C11);  
  stop();	
  
  clrscrn();
  c_Ab_b_mR(Ab_free,b_free);
  printf(" b_free:"); 
  p_mR(b_free, S6,P3,C11);
  printf("        b      FREEV");
  p_freeV(b_free, S6,P3);
  stop();

  f_mR(Ab);
  f_mR(Ab_free);
  f_mR(b_free);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

 Ab:
 -18.000 -549.000 -119.000 -715.000 -233.000 -640.000  +30.000 
+152.000  -42.000 -910.000 -730.000 +359.000 -799.000 +800.000 

 Ab:  gj_PP_mR(Ab,NO):
  +1.000   -0.276   -5.987   -4.803   +2.362   -5.257   +5.263 
  -0.000   +1.000   +0.409   +1.447   +0.344   +1.326   -0.225 



 Ab_free: put_zeroR_mR(Ab,Ab_free);
+1.000 -0.276 -5.987 -4.803 +2.362 -5.257 +5.263 +0.000 +0.000 +0.000 +0.000 
-0.000 +1.000 +0.409 +1.447 +0.344 +1.326 -0.225 +0.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 

 Press return to continue. 


 Ab_free: put_freeV_mR(Ab_free);
+1.000 -0.276 -5.987 -4.803 +2.362 -5.257 +5.263 +0.000 +0.000 +0.000 +0.000 
-0.000 +1.000 +0.409 +1.447 +0.344 +1.326 -0.225 +0.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 



 Ab_free: gj_PP_mR(Ab_free,YES);
+1.000 +0.000 +0.000 +0.000 +0.000 +0.000 +5.201 +5.874 +4.403 -2.457 +4.890 
+0.000 +1.000 +0.000 +0.000 +0.000 +0.000 -0.225 -0.409 -1.447 -0.344 -1.326 
+0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +1.000 

 Press return to continue. 


 b_free:
+5.201 +5.874 +4.403 -2.457 +4.890 
-0.225 -0.409 -1.447 -0.344 -1.326 
+0.000 +1.000 +0.000 +0.000 +0.000 
+0.000 +0.000 +1.000 +0.000 +0.000 
+0.000 +0.000 +0.000 +1.000 +0.000 
+0.000 +0.000 +0.000 +0.000 +1.000 

        b      FREEV
 x1 =  +5.201 +5.874*s +4.403*t -2.457*u +4.890*v
 x2 =  -0.225 -0.409*s -1.447*t -0.344*u -1.326*v
 x3 =  +0.000 +1.000*s +0.000*t +0.000*u +0.000*v
 x4 =  +0.000 +0.000*s +1.000*t +0.000*u +0.000*v
 x5 =  +0.000 +0.000*s +0.000*t +1.000*u +0.000*v
 x6 =  +0.000 +0.000*s +0.000*t +0.000*u +1.000*v

 Press return to continue.