Skip to content

Commit fab6cf6

Browse files
committed
Update docs examples to use Diagonal
1 parent d7f6976 commit fab6cf6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

docs/src/massmatrixdae/BDF.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CollapsedDocStrings = true
77
Multistep BDF methods, good for large stiff systems.
88

99
```julia
10+
using LinearAlgebra: Diagonal
1011
function rober(du, u, p, t)
1112
y₁, y₂, y₃ = u
1213
k₁, k₂, k₃ = p
@@ -15,9 +16,7 @@ function rober(du, u, p, t)
1516
du[3] = y₁ + y₂ + y₃ - 1
1617
nothing
1718
end
18-
M = [1.0 0 0
19-
0 1.0 0
20-
0 0 0]
19+
M = Diagonal([1.0, 1.0, 0])
2120
f = ODEFunction(rober, mass_matrix = M)
2221
prob_mm = ODEProblem(f, [1.0, 0.0, 0.0], (0.0, 1e5), (0.04, 3e7, 1e4))
2322
sol = solve(prob_mm, FBDF(), reltol = 1e-8, abstol = 1e-8)

docs/src/massmatrixdae/Rosenbrock.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ For larger systems look at multistep methods.
2020
## Example usage
2121

2222
```julia
23+
using LinearAlgebra: Diagonal
2324
function rober(du, u, p, t)
2425
y₁, y₂, y₃ = u
2526
k₁, k₂, k₃ = p
@@ -28,9 +29,7 @@ function rober(du, u, p, t)
2829
du[3] = y₁ + y₂ + y₃ - 1
2930
nothing
3031
end
31-
M = [1.0 0 0
32-
0 1.0 0
33-
0 0 0]
32+
M = Diagonal([1.0, 1.0, 0])
3433
f = ODEFunction(rober, mass_matrix = M)
3534
prob_mm = ODEProblem(f, [1.0, 0.0, 0.0], (0.0, 1e5), (0.04, 3e7, 1e4))
3635
sol = solve(prob_mm, Rodas5(), reltol = 1e-8, abstol = 1e-8)

0 commit comments

Comments
 (0)