Linear Algebra and the C Language/a0eh


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */   
void x_dif_sizes_mR(
double **A,
double **B,
char function[],
char matrices[]
)
{
  if( A[R_SIZE][C0]!=B[R_SIZE][C0]
                    ||
       A[C_SIZE][C0]!=B[C_SIZE][C0] )
    {
     printf("\n Error : %s\n",function);
     printf("\n The matrix must have the same size. %s \n",matrices);
     stop();
     exit(EXIT_FAILURE);
    }
}
/* ------------------------------------ */
int main(void)
{  
double **A     = i_mR(R4,R3);
double **B     = i_mR(R4,R6);

  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);
   
  dif_sizes_mR(A,B,"add_mR();","(A or B)");
  
  f_mR(A);
  f_mR(B);
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

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

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


 Error : add_mR();

 The matrix must have the same size. (A or B) 
 Press return to continue.