looks like M and O aren't big enough arrays for Piotr's code. Though, the segfaulting lines seem to be accessing M and O within reasonable bounds.
hmph. Even if I make M and O of size h*w*d instead of just h*w, I get the same segfault problem
got rid of factor of 'd' in malloc, since it's clearly not helping
aha! was abusing calloc's input args. calloc(num_elements, sizeof(float)) -> all zeros array of size num_elements*sizeof(float)
piotr's gradientMex runs now! before I go any further, I should probably add some more tests and I/O