Linear Algebra and the C Language/a09i


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00f3.c                 */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RAb  R4
#define   CA   C4
#define   Cb   C1
/* ------------------------------------ */
# define FREEV C3
/* ------------------------------------ */
#define  ARRAY FREEV
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ab[RAb*(CA+C1)]={
-1888.0,  +674.0, -1554.0,  -262.0, -1184.0, 
+2832.0, -1011.0, +2331.0,  +393.0, +1776.0, 
 -944.0,  +337.0,  -777.0,  -131.0,  -592.0, 
-3776.0, +1348.0, -3108.0,  -524.0, -2368.0        
};

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[ARRAY];
/* ------------------------------------ */
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 Arrays -- */
  for(c=C0; c<FREEV; c++)
     {
      u[c] = i_mR(CA,C1);
     vt[c] = i_mR(CA,C1); 
      
      c_c_mR(b_free,(c+C2), u[c],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<FREEV; 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<FREEV; 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]);   
       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]:
-1888.0000 
 +674.0000 
-1554.0000 
 -262.0000 

 v^t[1]:
+2832.0000 
-1011.0000 
+2331.0000 
 +393.0000 

 v^t[2]:
 -944.0000 
 +337.0000 
 -777.0000 
 -131.0000 

 Press return to continue. 


 FREEV: Without b


 u[0] :
   +0.3570 
   +1.0000 
   +0.0000 
   +0.0000 

 u[1] :
   -0.8231 
   +0.0000 
   +1.0000 
   +0.0000 

 u[2] :
   -0.1388 
   +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[1] u[0] = +0.0000
 v^t[1] u[1] = +0.0000
 v^t[1] u[2] = +0.0000
 v^t[2] u[0] = +0.0000
 v^t[2] u[1] = +0.0000
 v^t[2] u[2] = +0.0000



 Press return to continue.