File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 43
43
44
44
For this function, we know that the sparsity pattern of the Jacobian is a
45
45
` 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 ` :
51
50
52
51
``` julia
53
- using Symbolics, SparseArrays
52
+ using Symbolics
54
53
input = rand (30 )
55
54
output = similar (input)
56
55
sparsity_pattern = Symbolics. jacobian_sparsity (f,output,input)
57
- jac = Float64 .(sparse ( sparsity_pattern) )
56
+ jac = Float64 .(sparsity_pattern)
58
57
```
59
58
60
59
Now we call ` matrix_colors ` to get the colorvec vector for that matrix:
You can’t perform that action at this time.
0 commit comments