Skip to content

Commit 2c2923e

Browse files
Merge pull request #114 from SciML/AP_Jacobian_recursion
fix ArrayPartition ZeroMatrix, i.e. stiff ODEs on recursive AP
2 parents f4430c6 + d07ae7e commit 2c2923e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/array_partition.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ common_number(a, b) =
302302

303303
## Linear Algebra
304304

305-
ArrayInterface.zeromatrix(A::ArrayPartition) = ArrayInterface.zeromatrix(reduce(vcat,vec.(A.x)))
305+
ArrayInterface.zeromatrix(A::ArrayPartition) = ArrayInterface.zeromatrix(Vector(A))
306306

307307
LinearAlgebra.ldiv!(A::Factorization, b::ArrayPartition) = (x = ldiv!(A, Array(b)); copyto!(b, x))
308308
function LinearAlgebra.ldiv!(A::LU, b::ArrayPartition)

test/upstream.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,32 @@ F = ArrayPartition([0.0 0.0; 0.0 0.0],[0.0 0.0; 0.0 0.0])
2828
u0= ArrayPartition([0.1 1.2; 0.1 1.2], [0.1 1.2; 0.1 1.2])
2929
result = mymodel(F, u0)
3030
nlsolve(mymodel, u0)
31+
32+
# Nested ArrayPartition solves
33+
34+
dyn(u, p, t) = ArrayPartition(
35+
ArrayPartition(zeros(1), [0.0]),
36+
ArrayPartition(zeros(1), [0.0])
37+
)
38+
39+
solve(
40+
ODEProblem(
41+
dyn,
42+
ArrayPartition(
43+
ArrayPartition(zeros(1), [-1.0]),
44+
ArrayPartition(zeros(1), [0.75])
45+
),
46+
(0.0, 1.0)
47+
),AutoTsit5(Rodas5())
48+
)
49+
50+
@test_broken solve(
51+
ODEProblem(
52+
dyn,
53+
ArrayPartition(
54+
ArrayPartition(zeros(1), [-1.0]),
55+
ArrayPartition(zeros(1), [0.75])
56+
),
57+
(0.0, 1.0)
58+
),Rodas5()
59+
).retcode == :Success

0 commit comments

Comments
 (0)