Skip to content

Commit

Permalink
Fix color index
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Feb 16, 2024
1 parent 4d0c091 commit 9fa3444
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ext/SparseDiffToolsPolyesterExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function polyesterforwarddiff_color_jacobian(J::AbstractMatrix{<:Number}, f::F,
end

batch((length(p), min(length(p), Threads.nthreads()))) do _, start, stop
color_i = (start - 1) * chunksize + 1
for i in start:stop
partial_i = p[i]
color_i = i
t_ = reshape(eltype(t).(vecx, ForwardDiff.Partials.(partial_i)), size(t))
fx = f(t_)
for j in 1:chunksize
Expand All @@ -60,10 +60,11 @@ function polyesterforwarddiff_color_jacobian(J::AbstractMatrix{<:Number}, f::F,
@inbounds @simd for i in 1:length(rows_index_c)
J[rows_index_c[i], cols_index_c[i]] = dx[rows_index_c[i]]
end

Check warning on line 62 in ext/SparseDiffToolsPolyesterExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseDiffToolsPolyesterExt.jl#L62

Added line #L62 was not covered by tests
color_i += 1
end
end
end
return J
end

end
end
3 changes: 2 additions & 1 deletion ext/SparseDiffToolsPolyesterForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function (alg::ApproximateJacobianSparsity)(
fx, kwargs...)
end

function (alg::ApproximateJacobianSparsity)(ad::AutoSparsePolyesterForwardDiff, f::F, fx, x;
function (alg::ApproximateJacobianSparsity)(

Check warning on line 97 in ext/SparseDiffToolsPolyesterForwardDiffExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/SparseDiffToolsPolyesterForwardDiffExt.jl#L97

Added line #L97 was not covered by tests
ad::AutoSparsePolyesterForwardDiff, f::F, fx, x;
kwargs...) where {F}
@unpack ntrials, rng = alg
ck = __chunksize(ad, x)
Expand Down

0 comments on commit 9fa3444

Please sign in to comment.