Skip to content

Add num_types_in_tuple definitionUpdate vecjac_products.jl #162

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 5 commits into from
Nov 11, 2021
Merged
Changes from all commits
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
13 changes: 12 additions & 1 deletion src/differentiation/vecjac_products.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ function _numargs(f)
return (numparam-1) #-1 in v0.5 since it adds f as the first parameter
end


#Get the number of parameters of a Tuple type, i.e. the number of fields.

function num_types_in_tuple(sig)
length(sig.parameters)
end

function num_types_in_tuple(sig::UnionAll)
length(Base.unwrap_unionall(sig).parameters)
end

function num_vecjac!(
du,
f,
Expand Down Expand Up @@ -50,4 +61,4 @@ function num_vecjac(f, x, v, f0 = nothing)
du[i] = (((f0 .- _f0) ./ ϵ)'*vv)[1]
end
return vec(du)
end
end