Skip to content

Update README jacobian_sparsity #204

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

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ end

For this function, we know that the sparsity pattern of the Jacobian is a
`Tridiagonal` matrix. However, if we didn't know the sparsity pattern for
the Jacobian, we could use the `jacobian_sparsity` function to automatically
detect the sparsity pattern. This function is only available if you
load SparsityDetection.jl as well. We declare that the function `f` outputs a
vector of length 30 and takes in a vector of length 30, and `jacobian_sparsity` spits
out a `Sparsity` object which we can turn into a `SparseMatrixCSC`:
the Jacobian, we could use the `Symbolics.jacobian_sparsity` function to automatically
detect the sparsity pattern. We declare that the function `f` outputs a
vector of length 30 and takes in a vector of length 30, and `jacobian_sparsity` returns
a `SparseMatrixCSC`:

```julia
using Symbolics, SparseArrays
using Symbolics
input = rand(30)
output = similar(input)
sparsity_pattern = Symbolics.jacobian_sparsity(f,output,input)
jac = Float64.(sparse(sparsity_pattern))
jac = Float64.(sparsity_pattern)
```

Now we call `matrix_colors` to get the colorvec vector for that matrix:
Expand Down