@@ -306,10 +306,10 @@ reduced_indices0{N}(axs::Tuple{Vararg{Axis,N}}, region::Dims) =
306306
307307@inline reduced_indices {Ax<:Axis} (axs:: Tuple{Vararg{Axis}} , region:: Type{Ax} ) =
308308 _reduced_indices (reduced_axis, (), region, axs... )
309- @inline reduced_indices (axs:: Tuple{Vararg{Axis}} , region:: Axis ) =
310- _reduced_indices (reduced_axis, (), region, axs... )
311309@inline reduced_indices0 {Ax<:Axis} (axs:: Tuple{Vararg{Axis}} , region:: Type{Ax} ) =
312310 _reduced_indices (reduced_axis0, (), region, axs... )
311+ @inline reduced_indices (axs:: Tuple{Vararg{Axis}} , region:: Axis ) =
312+ _reduced_indices (reduced_axis, (), region, axs... )
313313@inline reduced_indices0 (axs:: Tuple{Vararg{Axis}} , region:: Axis ) =
314314 _reduced_indices (reduced_axis0, (), region, axs... )
315315
@@ -322,13 +322,22 @@ reduced_indices0(axs::Tuple{Vararg{Axis}}, region::Tuple) =
322322reduced_indices0 (axs:: Tuple{Vararg{Axis}} , region:: Tuple{Vararg{Axis}} ) =
323323 reduced_indices0 (reduced_indices0 (axs, region[1 ]), tail (region))
324324
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) =
328338 _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) =
330340 _reduced_indices (f, (out... , ax), chosen, axs... )
331- _reduced_indices (f, out, chosen) = out
332341
333342reduced_axis (ax) = ax (oftype (ax. val, Base. OneTo (1 )))
334343reduced_axis0 (ax) = ax (oftype (ax. val, length (ax. val) == 0 ? Base. OneTo (0 ) : Base. OneTo (1 )))
0 commit comments