Linear Algebra and the C Language/a09h


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00a2.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); 
double **A       = c_Ab_A_mR(Ab,         i_mR(RAb,     CA));     
double **b       = c_Ab_b_mR(Ab,         i_mR(RAb,     Cb)); 

double **Ax      =                       i_mR(RAb,     Cb + FREEV); 

  clrscrn();
  printf(" Ab:");
  p_mR(Ab, S8,P3,C11);
  
      gj_PP_mR(Ab,NO);                /* You can try with gj_PP_mR(Ab,YES); */
  put_zeroR_mR(Ab,Ab_free);           /* you get the same result!!!         */
  put_freeV_mR(Ab_free); 
      gj_PP_mR(Ab_free,YES); 
     c_Ab_b_mR(Ab_free,b_free);
  
  printf(" b:"); 
  p_mR(b, S8,P3,C11);     
  printf(" x:"); 
  p_mR(b_free, S8,P3,C11); 
  printf(" Ax:"); 
  p_mR(mul_mR(A,b_free, Ax), S8,P3,C11);   
  
  stop();

  f_mR(Ab);
  f_mR(Ab_free);
  f_mR(b_free);

  f_mR(A);
  f_mR(b);
  f_mR(Ax);
    
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
You can see that the vectors row of A are orthogonal to the vectors column of the free variables.

                                    <RowA,ColomnFreeV> = 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 

 b:
 +30.000 
+800.000 

 x:
  +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 

 Ax:
 +30.000   +0.000   +0.000   +0.000   +0.000 
+800.000   -0.000   -0.000   -0.000   -0.000 

 Press return to continue.