This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Sparsity detection missing values due to temporary storage? #16
Comments
It seems to be an intersection of #15 and global access: julia> const Z = Int[1,2]
2-element Array{Int64,1}:
1
2
# This works! --
julia> sparsity!([1,2],[2,3]) do du,u
Z[:] .= u[:]
du[1] = Z[1]
end
Explored path: SparsityDetection.Path(Bool[], 1)
2×2 SparseMatrixCSC{Bool,Int64} with 1 stored entry:
[1, 1] = 1
# This doesn't --
julia> sparsity!([1,2],[2,3]) do du,u
Z[:] .= u[:]
du[:] .= Z[:]
end
Explored path: SparsityDetection.Path(Bool[], 1)
2×2 SparseMatrixCSC{Bool,Int64} with 0 stored entries |
Interesting. So even the |
Yes. |
I fixed the above problem,
const N = 12
const My = Tridiagonal([1.0 for i in 1:N-1],[-2.0 for i in 1:N],[1.0 for i in 1:N-1])
My[1,2] = 2.0
My[end,end-1] = 2.0
function f(du,u,p,t)
mul!(du,My,u)
end
using SparsityDetection
input = rand(N,N)
output = similar(input)
sparsity_pattern = sparsity!(f,output,input,nothing,0.0)
# empty |
Ok that was actually not a problem, I screwed up while moving between branches and found a commit in the reflog which I had missed out in the #18. :/ :/ Does this look right to you for a 16x16 problem? |
It's a bit hard to do this one in my head, but that seems about right. A good test would be to calculate the full Jacobian with forward diff and then zero it out, or MTK. Of course, you can only do that on the small problems, and MTK will quickly out of memory if it's like 32x32 haha. |
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: