only do gradient computation when necessary
support obj.grad_method being a cell array (for gradient tests)