Skip to content

Commit 5dc0bf3

Browse files
committed
Split definitions for vectors and matrices
1 parent 94d2997 commit 5dc0bf3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

stdlib/LinearAlgebra/src/adjtrans.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ convert(::Type{Adjoint{T,S}}, A::Adjoint) where {T,S} = Adjoint{T,S}(convert(S,
139139
convert(::Type{Transpose{T,S}}, A::Transpose) where {T,S} = Transpose{T,S}(convert(S, A.parent))
140140

141141
# Strides for transposed strided arrays — but only if the elements are actually stored in memory
142-
Base.strides(A::Adjoint{<:Real, <:StridedArray}) = reverse(strides(A.parent))
143-
Base.strides(A::Transpose{<:Any, <:StridedArray}) = reverse(strides(A.parent))
142+
Base.strides(A::Adjoint{<:Real, <:StridedVector}) = (stride(A.parent, 2), stride(A.parent, 1))
143+
Base.strides(A::Transpose{<:Any, <:StridedVector}) = (stride(A.parent, 2), stride(A.parent, 1))
144+
# For matrices it's slightly faster to use reverse and avoid calling stride twice
145+
Base.strides(A::Adjoint{<:Real, <:StridedMatrix}) = reverse(strides(A.parent))
146+
Base.strides(A::Transpose{<:Any, <:StridedMatrix}) = reverse(strides(A.parent))
144147

145148
# for vectors, the semantics of the wrapped and unwrapped types differ
146149
# so attempt to maintain both the parent and wrapper type insofar as possible

0 commit comments

Comments
 (0)