From the NLsolve-docs i know that one can pass a jacobian to
nlsolve and make the solver treating the jacobian as sparse.
But what can I do when I don’t want to write down a jacobian of a PDE discretisation, and only know its sparsity pattern?
I tried to pass this pattern to
DiffEqDiffTools.forwarddiff_color_jacobian!. The resulting jacobian than to
nlsolve. And surprise… specifing a jacobian that way ended up with
nlsolve taking for ever to get a wrong /
Here is what I have tired.
using SparseDiffTools using DiffEqDiffTools using NLsolve f! = (dx, x) -> rhs!(dx, x, some_parameters, 0) # Discretized PDE jac = some_sparsity_pattern_ of_J_from_f! colors = matrix_colors(jac) j = (jac, x) -> forwarddiff_color_jacobian!(jac, f!, x, colorvec = colors) x0 = some_initial_guess #then I call nlsolve(f, j, x0) # slow nlsolve(f , x0) # fast and works (but want to have it faster)
Is there any way exploit the sparsity of the jacobian to speed up