Linear Algebra and the C Language/a0fu


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h" 
/* ------------------------------------ */
/* ------------------------------------ */
#define  ARRAY  A2
/* ------------------------------------ */
#define     RA  R5
#define     CA  C1
#define     CB  C2
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A[ARRAY];
double **B = i_mR(RA,CB);
int    i;
double s = 2;

  for(i=A0; i<ARRAY; i++)
 
      A[i] = r_mR(i_mR(RA,CA),99);           
  
  clrscrn();
  
    smul_mR(s,A[A0],A[A1]);
  
    for(i=C0; i<ARRAY; i++)
  
	  c_c_mR(A[i],C1, B,i+C1);
	  
  printf(" Multiply a vector by a scalar:\n\n");  
  
  printf("   %.0f A[0]  =  A[1] ",s);	     
  p_mR(B, S8,P0,C10);

  for(i=A0; i<ARRAY; i++)
  
       f_mR(A[i]); 
       
  f_mR(B);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Multiply a vector by a scalar:

Screen output example:

                                                                                       
 Multiply a vector by a scalar:

   2 A[0]  =  A[1] 
     +63     +126 
     -55     -110 
     +81     +162 
     +76     +152 
     -29      -58 


 Press   return to continue
 Press X return to stop