JuliaDiff / JuliaDiff/ForwardDiff.jl
Cancellation with sparse arrays
Open
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 1k
- Forks
- 160
- PR merge metrics
- No merged PRs in 30d
Description
Consider a function $f(t)$ such that $f(0)$ is the fully zero sparse vector. Apparently, ForwardDiff cannot compute $f'(0)$.
julia> using ForwardDiff: derivative
julia> using SparseArrays: sparse
julia> x = sparse([1.0]);
julia> dx = [1.0];
julia> derivative(t -> x + t * dx - x, 0) # incorrect
1-element SparseVector{Float64, Int64} with 0 stored entries
julia> derivative(t -> Vector(x) + t * dx - Vector(x), 0) # correct
1-element Vector{Float64}:
1.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Julia sparse-array and dense-array examples shown in the report, then trace ForwardDiff's derivative path for sparse results and cancellation at t=0. Done means the sparse-array case produces the expected derivative rather than an empty sparse vector, with regression coverage for the reported example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100