Linear Algebra and the C Language/a0fp


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00b.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define  ARRAY A3
/* ------------------------------------ */
void AplsB(int r,int c)
{
double **A[ARRAY];

  A[A0] = i_mR(r,c);
  A[A1] = i_mR(r,c);
  A[A2] = i_mR(r,c);

  rs_mR(A,ARRAY,9);

  clrscrn();

  printf(" A[0]: ");
  p_mR(A[0], S5,P0,C6);         
                         
  printf(" A[1]: ");
  p_mR(A[A1], S5,P0,C6);         

  printf(" A[0] + A[1]: ");
  p_mR(add_mR(A[A0],A[A1],A[A2]), S5,P0,C6);

  f_mR(A[A0]);
  f_mR(A[A1]);
  f_mR(A[A2]);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
  do{
        AplsB(rp_I(R5),rp_I(C5));
        
  }while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Create and initialize an array of matrices:

Screen output example:

                                                                                       
 A[0]: 
   -7    +5    -1    +7 
   -5    -1    -5    -2 
   +8    +7    +2    -6 
   -8    -6    +1    +2 

 A[1]: 
   -7    -7    -2    +3 
   +7    -9    -4    +9 
   -4    +9    -6    +2 
   -2    +5    -2    -3 

 A[0] + A[1]: 
  -14    -2    -3   +10 
   +2   -10    -9    +7 
   +4   +16    -4    -4 
  -10    -1    -1    -1 


 Press   return to continue
 Press X return to stop