Skip to content

Commit 592dc07

Browse files
committed
add test for forwarddiff static arrays
1 parent 0427d49 commit 592dc07

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/forwarddiff_overloads.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,31 @@ overload_x_p = solve(prob, UMFPACKFactorization())
193193
backslash_x_p = A \ b
194194

195195
@test (overload_x_p, backslash_x_p, rtol = 1e-9)
196+
197+
198+
# Test StaticArrays
199+
# They don't go through the overloads
200+
# But we should test that the overloads don't mess anything up
201+
function static_h(p)
202+
A = @SMatrix [p[1] p[2]+1 p[2]^3;
203+
3*p[1] p[1]+5 p[2] * p[1]-4;
204+
p[2]^2 9*p[1] p[2]]
205+
206+
b = SA[p[1] + 1, p[2] * 2, p[1]^2]
207+
208+
(A, b)
209+
end
210+
211+
function static_linsolve(p)
212+
A, b = static_h(p)
213+
prob = LinearProblem(A, b)
214+
solve(prob)
215+
end
216+
217+
function static_backslash(p)
218+
A, b = static_h(p)
219+
A \ b
220+
end
221+
222+
@test (ForwardDiff.jacobian(static_linsolve, [5.0, 5.0])
223+
ForwardDiff.jacobian(static_backslash, [5.0, 5.0]))

0 commit comments

Comments
 (0)