Skip to content

Commit

Permalink
Merge pull request #35 from SciML/gd/finitediff_types
Browse files Browse the repository at this point in the history
Add type parameters to AutoSparseFiniteDiff
  • Loading branch information
Vaibhavdixit02 authored Apr 3, 2024
2 parents 8d50cb9 + 67e8f7b commit 93b8c6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ADTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ end
Chooses [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl) while exploiting sparsity.
"""
struct AutoSparseFiniteDiff <: AbstractSparseFiniteDifferences end
Base.@kwdef struct AutoSparseFiniteDiff{T1, T2, T3} <: AbstractSparseFiniteDifferences
fdtype::T1 = Val(:forward)
fdjtype::T2 = fdtype
fdhtype::T3 = Val(:hcentral)
end

"""
AutoSparseForwardDiff{chunksize,T}
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ struct CustomTag end
adtype = AutoSparseFiniteDiff()
@test adtype isa ADTypes.AbstractADType
@test adtype isa AutoSparseFiniteDiff
@test adtype.fdtype === Val(:forward)
@test adtype.fdjtype === Val(:forward)
@test adtype.fdhtype === Val(:hcentral)

adtype = AutoSparseForwardDiff()
@test adtype isa ADTypes.AbstractADType
Expand Down

0 comments on commit 93b8c6c

Please sign in to comment.