diff --git a/stdlib/LinearAlgebra/src/adjtrans.jl b/stdlib/LinearAlgebra/src/adjtrans.jl index 3c5e3b6568c8c..8145b8b71a5e6 100644 --- a/stdlib/LinearAlgebra/src/adjtrans.jl +++ b/stdlib/LinearAlgebra/src/adjtrans.jl @@ -139,8 +139,11 @@ convert(::Type{Adjoint{T,S}}, A::Adjoint) where {T,S} = Adjoint{T,S}(convert(S, convert(::Type{Transpose{T,S}}, A::Transpose) where {T,S} = Transpose{T,S}(convert(S, A.parent)) # Strides for transposed strided arrays — but only if the elements are actually stored in memory -Base.strides(A::Adjoint{<:Real, <:StridedArray}) = reverse(strides(A.parent)) -Base.strides(A::Transpose{<:Any, <:StridedArray}) = reverse(strides(A.parent)) +Base.strides(A::Adjoint{<:Real, <:StridedVector}) = (stride(A.parent, 2), stride(A.parent, 1)) +Base.strides(A::Transpose{<:Any, <:StridedVector}) = (stride(A.parent, 2), stride(A.parent, 1)) +# For matrices it's slightly faster to use reverse and avoid calling stride twice +Base.strides(A::Adjoint{<:Real, <:StridedMatrix}) = reverse(strides(A.parent)) +Base.strides(A::Transpose{<:Any, <:StridedMatrix}) = reverse(strides(A.parent)) # for vectors, the semantics of the wrapped and unwrapped types differ # so attempt to maintain both the parent and wrapper type insofar as possible