Skip to content

Instantly share code, notes, and snippets.

using ForwardDiff
goo((x, y, z),) = [x^2*z, x*y*z, abs(z)-y]
foo((x, y, z),) = [x^2*z, x*y*z, abs(z)-y]
function foo(u::Vector{ForwardDiff.Dual{T,V,P}}) where {T,V,P}
# unpack: AoS -> SoA
vs = ForwardDiff.value.(u)
# you can play with the dimension here, sometimes it makes sense to transpose
ps = mapreduce(ForwardDiff.partials, hcat, u)
# get f(vs)
val = foo(vs)
@aiguofer
aiguofer / README.md
Last active April 27, 2023 19:12
Get info about running jupyter notebooks including memory consumption, how long they've been running, etc.
@brandur
brandur / force-reset.md
Last active January 3, 2022 16:07
Force pull request's diff to reset itself against target branch

Force pull request's diff to reset itself against target branch

git checkout feature-branch
# empty commit; don't worry, this will not show up in the final pull
git commit --allow-empty -m "Empty commit"
git push origin feature-branch
# hard reset to before empty commit
git reset --hard HEAD~
git push -f origin feature-branch