See the documentation of IGradientFunctionMultiDimTempl in mathcore/inc/Math/IFunction.h. If more efficient, Gradient can be overloaded directly. Since this is what our DoDerivative actually does, it would make more sense to put at least the outer for loop in Gradient. Perhaps we can keep the for loop body in DoDerivative, i.e. the actual partial derivative calculation.