Skip to content

Commit d2a5eb5

Browse files
Merge pull request #162 from QiyaoWei/master
Add num_types_in_tuple definitionUpdate vecjac_products.jl
2 parents 9c2d513 + bffee4f commit d2a5eb5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/differentiation/vecjac_products.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ function _numargs(f)
99
return (numparam-1) #-1 in v0.5 since it adds f as the first parameter
1010
end
1111

12+
13+
#Get the number of parameters of a Tuple type, i.e. the number of fields.
14+
15+
function num_types_in_tuple(sig)
16+
length(sig.parameters)
17+
end
18+
19+
function num_types_in_tuple(sig::UnionAll)
20+
length(Base.unwrap_unionall(sig).parameters)
21+
end
22+
1223
function num_vecjac!(
1324
du,
1425
f,
@@ -50,4 +61,4 @@ function num_vecjac(f, x, v, f0 = nothing)
5061
du[i] = (((f0 .- _f0) ./ ϵ)'*vv)[1]
5162
end
5263
return vec(du)
53-
end
64+
end

0 commit comments

Comments
 (0)