Skip to content

Automatic tangent generation for simple types #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 29, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds docstring
willtebbutt committed Jun 26, 2020
commit fabbea35894ef9ea5bbf10e45d2b7e03b5c6fb53
7 changes: 5 additions & 2 deletions src/generate_tangent.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
rand_tangent([rng::AbstractRNG], x)

Returns a randomly generated tangent vector appropriate for the primal value `x`.
"""
rand_tangent(x) = rand_tangent(Random.GLOBAL_RNG, x)

function rand_tangent(rng::AbstractRNG, x::Union{Symbol, AbstractChar, AbstractString})
@@ -17,5 +22,3 @@ end
function rand_tangent(rng::AbstractRNG, xs::T) where {T<:NamedTuple}
return Composite{T}(; map(x -> rand_tangent(rng, x), xs)...)
end

rand_tangent(x) = rand_tangent(Random.default_rng(), x)