@@ -120,35 +120,41 @@ similar_type(::Type{OptionallyStaticUnitRange{One,StaticInt{N1}}}, ::Type{Int},
120120
121121Return a valid range that maps to each index along dimension `d` of `A`.
122122"""
123- axes (a, dim) = axes (a, to_dims (a, dim))
124- axes (a, dims:: Tuple{Vararg{Any,K}} ) where {K} = (axes (a, first (dims)), axes (a, tail (dims))... )
125- axes (a, dims:: Tuple{T} ) where {T} = (axes (a, first (dims)), )
126- axes (a, :: Tuple{} ) = ()
127- function axes (a:: A , dim:: Integer ) where {A}
123+ @inline axes (a, dim) = axes (a, to_dims (a, dim))
124+ @inline axes (a, dims:: Tuple{Vararg{Any,K}} ) where {K} = (axes (a, first (dims)), axes (a, tail (dims))... )
125+ @inline axes (a, dims:: Tuple{T} ) where {T} = (axes (a, first (dims)), )
126+ @inline axes (a, :: Tuple{} ) = ()
127+ @inline function _axes (a:: A , dim:: Integer ) where {A}
128128 if parent_type (A) <: A
129129 return Base. axes (a, Int (dim))
130130 else
131- return axes (parent (a), to_parent_dims (A, dim))
131+ return _axes (parent (a), to_parent_dims (A, dim))
132132 end
133133end
134- function axes (A:: CartesianIndices{N} , dim:: Integer ) where {N}
134+ @inline function _axes (A:: CartesianIndices{N} , dim:: Integer ) where {N}
135135 if dim > N
136136 return static (1 ): static (1 )
137137 else
138138 return getfield (axes (A), Int (dim))
139139 end
140140end
141- function axes (A:: LinearIndices{N} , dim:: Integer ) where {N}
141+ @inline function _axes (A:: LinearIndices{N} , dim:: Integer ) where {N}
142142 if dim > N
143143 return static (1 ): static (1 )
144144 else
145145 return getfield (axes (A), Int (dim))
146146 end
147147end
148+ @inline _axes (:: LinearAlgebra.AdjOrTrans{T,V} , :: One ) where {T,V<: AbstractVector } = One (): One ()
149+ @inline axes (A:: AbstractArray , dim:: Integer ) = _axes (A, dim, False ())
150+ @inline axes (A:: AbstractArray{T,N} , :: StaticInt{M} ) where {T,N,M} = _axes (A, StaticInt {M} (), gt (StaticInt {M} (),StaticInt {N} ()))
151+ @inline _axes (:: Any , :: Any , :: True ) = One (): One ()
152+ @inline _axes (A:: AbstractArray , dim, :: False ) = _axes (A, dim)
148153
149- axes (A:: SubArray , dim:: Integer ) = Base. axes (A, Int (dim)) # TODO implement ArrayInterface version
150- axes (A:: ReinterpretArray , dim:: Integer ) = Base. axes (A, Int (dim)) # TODO implement ArrayInterface version
151- axes (A:: Base.ReshapedArray , dim:: Integer ) = Base. axes (A, Int (dim)) # TODO implement ArrayInterface version
154+
155+ @inline _axes (A:: SubArray , dim:: Integer ) = Base. axes (A, Int (dim)) # TODO implement ArrayInterface version
156+ @inline _axes (A:: ReinterpretArray , dim:: Integer ) = Base. axes (A, Int (dim)) # TODO implement ArrayInterface version
157+ @inline _axes (A:: Base.ReshapedArray , dim:: Integer ) = Base. axes (A, Int (dim)) # TODO implement ArrayInterface version
152158
153159"""
154160 axes(A)
0 commit comments