You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code yields the identity, as it should
function f1(dx, x)
for i in 1:length(x)
dx[i] = x[i]^2
end
end
input = rand(10)
output = similar(input)
sparsity_pattern1 = sparsity!(f1, output, input)
However, this code does not seem to work. It returns zeros everywhere instead of trues along the diagonal.
k = Dict(i => i for i in 1:10)
function f2(dx, x)
for i in 1:length(x)
dx[i] = x[k[i]]^2
end
end
input = rand(10)
output = similar(input)
sparsity_pattern2 = sparsity!(f2, output, input)
The envisioned use case is when you have a dictionary of Symbol values mapped to indices so that users can reference the particular index of a vector or a matrix by the name of what the entry is meant to be. An example package which extensively uses this approach is DSGE.jl.
The following code yields the identity, as it should
However, this code does not seem to work. It returns zeros everywhere instead of trues along the diagonal.
The envisioned use case is when you have a dictionary of
Symbolvalues mapped to indices so that users can reference the particular index of a vector or a matrix by the name of what the entry is meant to be. An example package which extensively uses this approach is DSGE.jl.Note, I'm using Julia 1.1.