Support gradient computation in Solver.
All the newly added four functions are untested though. Don't use
them right now! The lack of interest in testing them is because we
will override new verision in BFGS anyway.