Linear Algebra and the C Language/a0a6


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00e.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **u       = r_mR(i_mR(r,C1),9.);
double **v       = r_mR(i_mR(r,C1),9.);
double **projuv  =      i_mR(r,C1);

  clrscrn();
  printf(" u :");
  p_mR(u,S3,P0,C6);
  printf(" v :");
  p_mR(v,S3,P0,C6);

  proj_mR(u,v,projuv);
  
  printf(" Vector component of u along v \n\n");  

  printf(" projuv :           (<u,v> / ||v||^2) * v  ");

  p_mR(projuv,S3,P3,C6);

  f_mR(u);
  f_mR(v);
  f_mR(projuv);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun(rp_I(2)+R2);


} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

                                                                                       
 u :
 -8 
 +5 
 +9 
 +7 

 v :
 -7 
 -9 
 +5 
 -3 

 Vector component of u along v 

 projuv :             (<u,v> / ||v||^2) * v   
-1.494 
-1.921 
+1.067 
-0.640 


 Press   return to continue
 Press X return to stop