Add support for sparse differentiable function.
Add sparse matrices support.