Skip to content

Commit b0ae31f

Browse files
Merge pull request #204 from bowenszhu/fix-readme
Update README `jacobian_sparsity`
2 parents e89cc31 + 8ff4930 commit b0ae31f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,17 @@ end
4343

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

5251
```julia
53-
using Symbolics, SparseArrays
52+
using Symbolics
5453
input = rand(30)
5554
output = similar(input)
5655
sparsity_pattern = Symbolics.jacobian_sparsity(f,output,input)
57-
jac = Float64.(sparse(sparsity_pattern))
56+
jac = Float64.(sparsity_pattern)
5857
```
5958

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

0 commit comments

Comments
 (0)