// Uses malloc to create a matrix, by Tim Jones @ Drexel University

double **mmatrix(int r, int c)
{

int row, col;
double **matrix;
matrix = (double **)malloc((size_t)(r * sizeof(double *)));
assert(matrix != NULL);

for (row = 0; row < r; row++) 
   {
     matrix[row] = (double *)malloc((size_t)(c * sizeof(double)));
     assert(matrix[row] != NULL);
     for (col = 0; col < c; col++)  matrix[row][col] = 0;  //set all to zero
    }
 return matrix;
}
