Skip to content

Commit 93b8c6c

Browse files
Merge pull request #35 from SciML/gd/finitediff_types
Add type parameters to AutoSparseFiniteDiff
2 parents 8d50cb9 + 67e8f7b commit 93b8c6c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/ADTypes.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ end
168168
169169
Chooses [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl) while exploiting sparsity.
170170
"""
171-
struct AutoSparseFiniteDiff <: AbstractSparseFiniteDifferences end
171+
Base.@kwdef struct AutoSparseFiniteDiff{T1, T2, T3} <: AbstractSparseFiniteDifferences
172+
fdtype::T1 = Val(:forward)
173+
fdjtype::T2 = fdtype
174+
fdhtype::T3 = Val(:hcentral)
175+
end
172176

173177
"""
174178
AutoSparseForwardDiff{chunksize,T}

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ struct CustomTag end
7777
adtype = AutoSparseFiniteDiff()
7878
@test adtype isa ADTypes.AbstractADType
7979
@test adtype isa AutoSparseFiniteDiff
80+
@test adtype.fdtype === Val(:forward)
81+
@test adtype.fdjtype === Val(:forward)
82+
@test adtype.fdhtype === Val(:hcentral)
8083

8184
adtype = AutoSparseForwardDiff()
8285
@test adtype isa ADTypes.AbstractADType

0 commit comments

Comments
 (0)