-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
I have been willing to try this fantastic tool but I am not able to get the result. Basically, the call to forwarddiff_color_jacobian
seems slow and it does not return a sparse jacobian.
It is possible that I am not using your package very well... I am posting this in case of a bug:
using SparsityDetection, SparseArrays, SparseDiffTools, ForwardDiff, Test
source_term(x; a = 0.5, b = 0.01) = 1 + (x + a*x^2)/(1 + b*x^2)
function F_chan(x, α, β = 0.)
f = similar(x)
n = length(x)
f[1] = x[1] - β
f[n] = x[n] - β
for i=2:n-1
f[i] = (x[i-1] - 2 * x[i] + x[i+1]) * (n-1)^2 + α * source_term(x[i], b = β)
end
return f
end
N = 100
_input = rand(N)
_output = similar(_input)
The jacobian is
_J = ForwardDiff.jacobian(x -> F_chan(x, 3.,0.01), _input) |> sparse
colors = matrix_colors(_J)
@show maximum(colors) # this returns 3
Then, the issue:
# does not return sparse array
J = @time forwarddiff_color_jacobian(x -> F_chan(x, 3.,0.01), _output; colorvec = colors, sparsity = _J, jac_prototype = _J)
Thank you for your help,
Metadata
Metadata
Assignees
Labels
No labels