Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparsity Detection not working in combination with OffsetArrays #154

Open
boriskaus opened this issue Aug 26, 2021 · 0 comments
Open

Sparsity Detection not working in combination with OffsetArrays #154

boriskaus opened this issue Aug 26, 2021 · 0 comments

Comments

@boriskaus
Copy link

In some cases, it is quite handy to use OffsetArrays within the residual routine. Yet it seems that the sparsity pattern cannot be detected in that case.

Following the example in the Readme:

fcalls = 0
function f_offset(y,x_in) # in-place
  global fcalls += 1
  x = OffsetArray(x_in,1:length(x_in))
  for i in 2:length(x)-1
    y[i] = x[i-1] - 2x[i] + x[i+1]
  end
  y[1] = -2x[1] + x[2]
  y[end] = x[end-1] - 2x[end]
  nothing
end

julia> using SparsityDetection, SparseArrays, OffsetArrays
julia> input = rand(30)
julia> output = similar(input)
julia> sparsity_pattern = jacobian_sparsity(f_offset,output,input)
Explored path: SparsityDetection.Path(Bool[], 1)
30×30 SparseMatrixCSC{Bool, Int64} with 0 stored entries:⠀⠀⠀⠀⠀⠀⠀⠀⠀

I realize that the SparsityDetection package is deprecated in favor of ModelingToolkit.jl, but within the documentation of the last package I did not find an example that replaces the lines above (and can thus not check if it has been fixed).
An example would be highly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant