Linear Algebra and the C Language/a09t


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as:   c00a3.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RAb  R2
#define   CA   C6
#define   Cb   C1
/* ------------------------------------ */
# define FREEV C4
/* ------------------------------------ */
#define  ARRAY FREEV
/* ------------------------------------ */
/* ------------------------------------ */
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 **At      = transpose_mR(A,       i_mR(CA,      RAb));  
/* ------------------------------------ */
double **u [ARRAY];
double **vt[RAb];
/* ------------------------------------ */
int c,r;

      gj_PP_mR(Ab,NO);                
  put_zeroR_mR(Ab,Ab_free);           
  put_freeV_mR(Ab_free); 
      gj_PP_mR(Ab_free,YES); 
     c_Ab_b_mR(Ab_free,b_free);
     
/*  Initialisation of the Array: u[c]   */
  for(c=C0; c<FREEV; c++)
     {
      u[c] = i_mR(CA,C1);    
      c_c_mR(b_free,(c+C2), u[c],C1);            
     }
/* ------------------------------------ */

/*  Initialisation of the Array: vt[c]  */
  for(c=C0; c<RAb; c++)
     {
     vt[c] = i_mR(CA,C1);     
      c_c_mR(    At,(c+C1),vt[c],C1);      
     }
/* ------------------------------------ */

  clrscrn();
  printf(" At: The transpose columns of A\n\n\n");
  for(c=C0; c<RAb; c++)
     {
	  printf(" v^t[%d]:",c);      
      p_mR(vt[c], S10,P4,C1); 
     } 
  stop();

  clrscrn();
  printf(" FREEV: Without b\n\n\n");
  for(c=C0; c<FREEV; c++)
     {
	  printf(" u[%d] :",c);      
      p_mR(u[c], S10,P4,C1);
     } 
  stop();

  clrscrn();
  printf(" \n\n\n"
    " You can see that the vectors row of A, (Columns of At: v^t ),  \n"
    " are orthogonal to the vectors column of the free variables (u).\n"
    "\n\n     <u,v> = v^t u                                      \n\n");

  for(c=C0; c<RAb; c++) 
  
    for(r=C0;  r<FREEV; r++) 

         printf(" v^t[%d] u[%d] = %+.4f\n",c,r, dot_R(vt[c],u[r])); 
              
  printf("\n\n\n");
  stop();
  
  f_mR(Ab);
  f_mR(Ab_free);
  f_mR(b_free);

/* --- Free the memory of the Arrays -- */
  for(c=C0; c<FREEV; c++)
  
       f_mR( u[c]);   

      
  for(c=C0; c<RAb; c++)

       f_mR(vt[c]);      
/* ------------------------------------ */

  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:

 At: The transpose columns of A


 v^t[0]:
  -18.0000 
 -549.0000 
 -119.0000 
 -715.0000 
 -233.0000 
 -640.0000 

 v^t[1]:
 +152.0000 
  -42.0000 
 -910.0000 
 -730.0000 
 +359.0000 
 -799.0000 

 Press return to continue. 


 FREEV: Without b


 u[0] :
   +5.8737 
   -0.4093 
   +1.0000 
   +0.0000 
   +0.0000 
   +0.0000 

 u[1] :
   +4.4029 
   -1.4467 
   +0.0000 
   +1.0000 
   +0.0000 
   +0.0000 

 u[2] :
   -2.4569 
   -0.3439 
   +0.0000 
   +0.0000 
   +1.0000 
   +0.0000 

 u[3] :
   +4.8902 
   -1.3261 
   +0.0000 
   +0.0000 
   +0.0000 
   +1.0000 

 Press return to continue. 


 You can see that the vectors row of A, (Columns of At: v^t ),  
 are orthogonal to the vectors column of the free variables (u).


     <u,v> = v^t u                                      

 v^t[0] u[0] = +0.0000
 v^t[0] u[1] = +0.0000
 v^t[0] u[2] = +0.0000
 v^t[0] u[3] = +0.0000
 v^t[1] u[0] = -0.0000
 v^t[1] u[1] = -0.0000
 v^t[1] u[2] = -0.0000
 v^t[1] u[3] = -0.0000



 Press return to continue.