@@ -306,10 +306,10 @@ reduced_indices0{N}(axs::Tuple{Vararg{Axis,N}}, region::Dims) =
306
306
307
307
@inline reduced_indices {Ax<:Axis} (axs:: Tuple{Vararg{Axis}} , region:: Type{Ax} ) =
308
308
_reduced_indices (reduced_axis, (), region, axs... )
309
- @inline reduced_indices (axs:: Tuple{Vararg{Axis}} , region:: Axis ) =
310
- _reduced_indices (reduced_axis, (), region, axs... )
311
309
@inline reduced_indices0 {Ax<:Axis} (axs:: Tuple{Vararg{Axis}} , region:: Type{Ax} ) =
312
310
_reduced_indices (reduced_axis0, (), region, axs... )
311
+ @inline reduced_indices (axs:: Tuple{Vararg{Axis}} , region:: Axis ) =
312
+ _reduced_indices (reduced_axis, (), region, axs... )
313
313
@inline reduced_indices0 (axs:: Tuple{Vararg{Axis}} , region:: Axis ) =
314
314
_reduced_indices (reduced_axis0, (), region, axs... )
315
315
@@ -322,13 +322,22 @@ reduced_indices0(axs::Tuple{Vararg{Axis}}, region::Tuple) =
322
322
reduced_indices0 (axs:: Tuple{Vararg{Axis}} , region:: Tuple{Vararg{Axis}} ) =
323
323
reduced_indices0 (reduced_indices0 (axs, region[1 ]), tail (region))
324
324
325
- @inline _reduced_indices {name} (f, out, chosen:: Type{Axis{name}} , ax:: Axis{name} , axs... ) =
326
- _reduced_indices (f, (out... , f (ax)), chosen, axs... )
327
- @inline _reduced_indices {name} (f, out, chosen:: Axis{name} , ax:: Axis{name} , axs... ) =
325
+ @pure samesym {n1,n2} (:: Type{Axis{n1}} , :: Type{Axis{n2}} ) = Val {n1==n2} ()
326
+ samesym {n1,n2,T1,T2} (:: Type{Axis{n1,T1}} , :: Type{Axis{n2,T2}} ) = samesym (Axis{n1},Axis{n2})
327
+ samesym {n1,n2} (:: Type{Axis{n1}} , :: Axis{n2} ) = samesym (Axis{n1}, Axis{n2})
328
+ samesym {n1,n2} (:: Axis{n1} , :: Type{Axis{n2}} ) = samesym (Axis{n1}, Axis{n2})
329
+ samesym {n1,n2} (:: Axis{n1} , :: Axis{n2} ) = samesym (Axis{n1}, Axis{n2})
330
+
331
+ @inline _reduced_indices {Ax<:Axis} (f, out, chosen:: Type{Ax} , ax:: Axis , axs... ) =
332
+ __reduced_indices (f, out, samesym (chosen, ax), chosen, ax, axs)
333
+ @inline _reduced_indices (f, out, chosen:: Axis , ax:: Axis , axs... ) =
334
+ __reduced_indices (f, out, samesym (chosen, ax), chosen, ax, axs)
335
+ _reduced_indices (f, out, chosen) = out
336
+
337
+ @inline __reduced_indices (f, out, :: Val{true} , chosen, ax, axs) =
328
338
_reduced_indices (f, (out... , f (ax)), chosen, axs... )
329
- @inline _reduced_indices (f, out, chosen, ax:: Axis , axs... ) =
339
+ @inline __reduced_indices (f, out, :: Val{false} , chosen, ax, axs) =
330
340
_reduced_indices (f, (out... , ax), chosen, axs... )
331
- _reduced_indices (f, out, chosen) = out
332
341
333
342
reduced_axis (ax) = ax (oftype (ax. val, Base. OneTo (1 )))
334
343
reduced_axis0 (ax) = ax (oftype (ax. val, length (ax. val) == 0 ? Base. OneTo (0 ) : Base. OneTo (1 )))
0 commit comments