Skip to content

Commit

Permalink
added setindex! for AD primitives (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThummeTo committed Nov 24, 2023
1 parent 5dec4c1 commit 4e53a05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "FMICore"
uuid = "8af89139-c281-408e-bce2-3005eb87462f"
authors = ["TT <tobias.thummerer@informatik.uni-augsburg.de>", "LM <lars.mikelsons@informatik.uni-augsburg.de>", "JK <josef.kircher@student.uni-augsburg.de>"]
version = "0.19.1"
version = "0.19.2"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
ChainRulesCore = "1.16.0"
ChainRulesCore = "1.16.0 - 1.18"
Dates = "1"
Requires = "1.3.0"
julia = "1.6"
9 changes: 9 additions & 0 deletions src/extensions/FMISensitivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ function unsense(e::ForwardDiff.Dual)
return ForwardDiff.value(e)
end

# set sensitive primitives (this is intentionally NO additional dispatch for `setindex!`)
function sense_setindex!(A::Vector{Float64}, x::ForwardDiff.Dual, i::Int64)
return setindex!(A, undual(x), i)
end

function sense_setindex!(A::Vector{Float64}, x::ReverseDiff.TrackedReal, i::Int64)
return setindex!(A, untrack(x), i)
end

5 changes: 5 additions & 0 deletions src/sense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ end
function unsense(e)
return e
end

# set sensitive primitives (this is intentionally NO additional dispatch for `setindex!`)
function sense_setindex!(A, x, i)
return setindex!(A, x, i)
end

2 comments on commit 4e53a05

@ThummeTo
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/95903

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.19.2 -m "<description of version>" 4e53a054b0015460dc500f23aa66fd576490188f
git push origin v0.19.2

Please sign in to comment.