Skip to content

Commit

Permalink
Split definitions for vectors and matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Sep 14, 2018
1 parent 94d2997 commit 5dc0bf3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stdlib/LinearAlgebra/src/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5dc0bf3

Please sign in to comment.