Linear Algebra and the C Language/a0ej


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */   
void x_canImul_mR(
double **A,
double **B,
double **AB,
char function[],
char matrices[]
)
{
  if (         ( A[C_SIZE][C0] != B[R_SIZE][C0] )
                               ||
               ( A[R_SIZE][C0] != AB[R_SIZE][C0] )
                               ||
               ( B[C_SIZE][C0] != AB[C_SIZE][C0] ) )
    {
     printf("\n Error : %s\n",function);
     printf("\n mul_mR(); Verify the size of the matrices. %s \n",
              matrices);
     stop();
     exit(EXIT_FAILURE);
    }
}
/* ------------------------------------ */
int main(void)
{  
double **A     = i_mR(R2,R4);
double **B     = i_mR(R4,R3);
double **AB    = i_mR(R3,R3);

  clrscrn();
  
  printf(" A[R%d,C%d]:",rsize_R(A),csize_R(A));
  p_mR(A, S4,P0,C6);

  printf(" B[R%d,C%d]:",rsize_R(B),csize_R(B));
  p_mR(B, S4,P0,C6);

  printf(" AB[R%d,C%d]:",rsize_R(AB),csize_R(AB));
  p_mR(AB, S4,P0,C6);
   
  x_canImul_mR(A,B,AB,"main();","(A or B or AB)");
  
  f_mR(A);
  f_mR(B);
  f_mR(AB);
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

                                                                                       
 A[R2,C4]: 
  +0   +0   +0   +0 
  +0   +0   +0   +0 

 B[R4,C3]: 
  +0   +0   +0 
  +0   +0   +0 
  +0   +0   +0 
  +0   +0   +0 

 AB[R3,C3]: 
  +0   +0   +0 
  +0   +0   +0 
  +0   +0   +0 


 Error : main();

 mul_mR(); Verify the size of the matrices. (A or B or AB) 
 Press return to continue.