I am cleaning up some pointer arithmetic stuff for multi-dimensional C style arrays. I managed to replace the code with a std::inner_product minus a std::accumulate (to accomodate for the fact that the upper array bound is exclusive, ie one-past-the-end).