Linear Algebra and the C Language/a05r


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(void)
{ 
double **U_T = r_mR(i_mR(R1, C3), 9);  
double **V_T = r_mR(i_mR(R1, C3), 9);   
double **W_T = r_mR(i_mR(R1, C3), 9);
 
double **VxU         = UxV_mR(V_T,U_T,    i_mR(R1,C3));
double **WxU         = UxV_mR(W_T,U_T,    i_mR(R1,C3));
double **VxU_pls_WxU = add_mR(VxU,WxU,    i_mR(R1,C3));

double **VplusW      = add_mR(V_T,W_T,    i_mR(R1,C3));

double **VplusW_xU   = UxV_mR(VplusW,U_T, i_mR(R1,C3));
    
  clrscrn();       
  printf("  u_T:");
  p_mR(U_T, S4, P0, C6);
  printf("  v_T:");
  p_mR(V_T, S4, P0, C6);
  printf("  w_T:");
  p_mR(W_T, S4, P0, C6);

  printf("\n\n"
         "    (v+w) x u:");    
  p_mR(VplusW_xU, S5, P0, C6);                       
  printf("    (vxu) + (wxu):");
  p_mR(VxU_pls_WxU, S5, P0, C6);
  
  f_mR(U_T); 
  f_mR(V_T);
  f_mR(W_T);  

  f_mR(VxU); 
  f_mR(WxU);
  f_mR(VxU_pls_WxU); 

  f_mR(VplusW);
  f_mR(VplusW_xU);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
do
{  
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
(v+w) x u == (vxu) + (wxu):.

Screen output example:

  u_T  :
  +3   +6   -4 

  v_T  :
  +9   +1   +6 

  w_T  :
  -9   +2   -7 



    (v+w) x u     :
   -6    -3    -9 

    (vxu) + (wxu) :
   -6    -3    -9 


 Press   return to continue
 Press X return to stop