@@ -95,23 +95,43 @@ function shuffle_up(r::UniformBundle{N, B, U}) where {N, B, U}
95
95
end
96
96
@ChainRulesCore . non_differentiable shuffle_up (r:: UniformBundle )
97
97
98
- function shuffle_up_bundle (r:: Diffractor.TaylorBundle {1, <:TaylorBundle{<:Any, Float64 }} )
98
+ function shuffle_up_bundle (r:: Diffractor.TangentBundle {1, <:TaylorBundle{1 }} )
99
99
a = primal (r)
100
100
b = partial (r, 1 )
101
101
z₀ = primal (a)
102
102
z₁ = partial (a, 1 )
103
103
z₂ = b. primal
104
- z₁₂ = b. tagent
104
+ z₁₂ = only (b. tangent. coeffs)
105
+
106
+ if z₁ == z₂
107
+ return TaylorBundle {2} (z₀, (z₁, z₁₂))
108
+ else
109
+ return ExplicitTangentBundle {2} (z₀, (z₁, z₂, z₁₂))
110
+ end
111
+ end
112
+
113
+ function shuffle_up_bundle (r:: Diffractor.TangentBundle{1, <:ExplicitTangentBundle{1}} )
114
+ a = primal (r)
115
+ b = partial (r, 1 )
116
+ z₀ = primal (a)
117
+ z₁ = partial (a, 1 )
118
+ z₂ = b. primal
119
+ z₂ = b. primal
120
+ z₁₂ = only (b. tangent. coeffs)
105
121
if z₁ == z₂
106
122
return TaylorBundle {2} (z₀, (z₁, z₁₂))
107
123
else
108
124
return ExplicitTangentBundle {2} (z₀, (z₁, z₂, z₁₂))
109
125
end
110
126
end
111
127
128
+
112
129
function shuffle_up_bundle (r:: UniformBundle{1, <:UniformBundle{N, B, U}} ) where {N, B, U}
113
130
return UniformBundle {N+1, B, U} (primal (primal (r)))
114
131
end
132
+ function shuffle_up_bundle (r:: UniformBundle{1, <:UniformBundle{1, B, U}} ) where {B, U} # break ambig
133
+ return UniformBundle {2, B, U} (primal (primal (r)))
134
+ end
115
135
116
136
function shuffle_down_bundle (b:: ExplicitTangentBundle{N, B} ) where {N, B}
117
137
error (" TODO" )
166
186
function (:: ∂☆shuffle{N})(args:: AbstractTangentBundle{N} ...) where {N}
167
187
∂☆p = ∂☆ {N-1} ()
168
188
downargs = map (shuffle_down, args)
189
+ # @info "∂☆shuffle{N}" args downargs
169
190
tupargs = ∂vararg {N-1} ()(map (first_partial, downargs)... )
170
191
∂☆p (ZeroBundle {N-1} (frule), #= ZeroBundle{N-1}(DiffractorRuleConfig()), =# tupargs, map (primal, downargs)... )
171
192
end
0 commit comments