Linear Algebra and the C Language/a09d


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00b2.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RAb  R2
#define   CA   C6
#define   Cb   C1
/* ------------------------------------ */
# define FREEV C5
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ab[RAb*(CA+C1)]={
     -18, -549, -119, -715, -233, -640,   30,
     -18, -549, -119, -715, -233, -640,   30 
};

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 
 -18.000 -549.000 -119.000 -715.000 -233.000 -640.000  +30.000 

 b:
 +30.000 
 +30.000 

 x:
  -1.667  -30.500   -6.611  -39.722  -12.944  -35.556 
  +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   +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   +0.000   +0.000   +1.000 

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

 Press return to continue.