finite-difference-gradient.hxx: Fix compilation error.

When instantiated with sparse matrices, wrong matrix type were used.
tests/numeric-quadratic-function.cc: check gradient and jacobian