@@ -120,35 +120,41 @@ similar_type(::Type{OptionallyStaticUnitRange{One,StaticInt{N1}}}, ::Type{Int},
120
120
121
121
Return a valid range that maps to each index along dimension `d` of `A`.
122
122
"""
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}
128
128
if parent_type (A) <: A
129
129
return Base. axes (a, Int (dim))
130
130
else
131
- return axes (parent (a), to_parent_dims (A, dim))
131
+ return _axes (parent (a), to_parent_dims (A, dim))
132
132
end
133
133
end
134
- function axes (A:: CartesianIndices{N} , dim:: Integer ) where {N}
134
+ @inline function _axes (A:: CartesianIndices{N} , dim:: Integer ) where {N}
135
135
if dim > N
136
136
return static (1 ): static (1 )
137
137
else
138
138
return getfield (axes (A), Int (dim))
139
139
end
140
140
end
141
- function axes (A:: LinearIndices{N} , dim:: Integer ) where {N}
141
+ @inline function _axes (A:: LinearIndices{N} , dim:: Integer ) where {N}
142
142
if dim > N
143
143
return static (1 ): static (1 )
144
144
else
145
145
return getfield (axes (A), Int (dim))
146
146
end
147
147
end
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)
148
153
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
152
158
153
159
"""
154
160
axes(A)
0 commit comments