@@ -14,9 +14,9 @@ struct ∂☆new{N}; end
14
14
# but the nth order case does also work for this
15
15
function (:: ∂☆new{1 })(B:: Type , xs:: AbstractTangentBundle{1} ...)
16
16
primal_args = map (primal, xs)
17
- the_primal = B <: Tuple ? B ( primal_args) : B (primal_args ... )
18
-
19
- tangent_tup = map (x -> partial (x, 1 ) , xs)
17
+ the_primal = _construct (B, primal_args)
18
+
19
+ tangent_tup = map (first_partial , xs)
20
20
the_partial = if B<: Tuple
21
21
Tangent {B, typeof(tangent_tup)} (tangent_tup)
22
22
else
29
29
30
30
function (:: ∂☆new{N})(B:: Type , xs:: AbstractTangentBundle{N} ...) where {N}
31
31
primal_args = map (primal, xs)
32
- the_primal = B <: Tuple ? B ( primal_args) : B (primal_args ... )
32
+ the_primal = _construct (B, primal_args)
33
33
34
34
the_partials = ntuple (Val {N} ()) do ii
35
35
iith_order_type = ii== 1 ? B : Any # the type of the higher order tangents isn't worth tracking
@@ -46,6 +46,10 @@ function (::∂☆new{N})(B::Type, xs::AbstractTangentBundle{N}...) where {N}
46
46
return TaylorBundle {N, B} (the_primal, the_partials)
47
47
end
48
48
49
+ _construct (:: Type{B} , args) where B<: Tuple = B (args)
50
+ # Hack for making things that do not have public constructors constructable:
51
+ @generated _construct (B:: Type , args) = :($ (Expr (:splatnew , :B , :args )))
52
+
49
53
@generated (:: ∂☆new{N})(B:: Type ) where {N} = return :(ZeroBundle {$N} ($ (Expr (:new , :B ))))
50
54
51
55
# Sometimes we don't know whether or not we need to the ZeroBundle when doing
0 commit comments