diff --git a/src/differentiation/vecjac_products.jl b/src/differentiation/vecjac_products.jl index eecd1ae1..c40bcc06 100644 --- a/src/differentiation/vecjac_products.jl +++ b/src/differentiation/vecjac_products.jl @@ -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, @@ -50,4 +61,4 @@ function num_vecjac(f, x, v, f0 = nothing) du[i] = (((f0 .- _f0) ./ ϵ)'*vv)[1] end return vec(du) -end \ No newline at end of file +end