Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit f81b25e

Browse files
committed
Merge branch 'master' into travis-up
2 parents 5cdc2ac + 94c4199 commit f81b25e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseDiffTools"
22
uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
33
authors = ["Pankaj Mishra <[email protected]>", "Chris Rackauckas <[email protected]>"]
4-
version = "0.10.1"
4+
version = "0.10.2"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/differentiation/compute_jacobian_ad.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ function forwarddiff_color_jacobian(f,x::AbstractArray{<:Number},jac_cache::Forw
120120
for j in 1:chunksize
121121
col_index = (i-1)*chunksize + j
122122
(col_index > ncols) && return J
123-
J = J + mapreduce(i -> i==col_index ? partials.(vec(fx), j) : zeros(nrows), hcat, 1:ncols)
123+
Ji = mapreduce(i -> i==col_index ? partials.(vec(fx), j) : zeros(nrows), hcat, 1:ncols)
124+
J = J + (size(Ji)!=size(J) ? reshape(Ji,size(J)) : Ji) #branch when size(dx) == (1,) => size(Ji) == (1,) while size(J) == (1,1)
124125
end
125126
end
126127
end

test/test_ad.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,10 @@ J = forwarddiff_color_jacobian(oopf,x)
218218
@test J Matrix(I,4,4)
219219
J = zero(J)
220220
forwarddiff_color_jacobian!(J,iipf,x,dx=similar(x))
221-
@test J Matrix(I,4,4)
221+
@test J Matrix(I,4,4)
222+
223+
#1x1 SVector test
224+
x = SVector{1}([1.])
225+
f(x) = x
226+
J = forwarddiff_color_jacobian(f,x)
227+
@test J SMatrix{1,1}([1.])

0 commit comments

Comments
 (0)