Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ axes(A::AdjOrTrans) = reverse(axes(A.parent))
length(A::AdjOrTrans) = length(A.parent)
size(v::AdjOrTransAbsVec) = (1, length(v.parent))
size(A::AdjOrTransAbsMat) = reverse(size(A.parent))
axes(v::AdjOrTransAbsVec) = (Base.OneTo(1), axes(v.parent)...)
axes(v::AdjOrTransAbsVec) = (axes(v.parent,2), axes(v.parent)...)
axes(A::AdjOrTransAbsMat) = reverse(axes(A.parent))
IndexStyle(::Type{<:AdjOrTransAbsVec}) = IndexLinear()
IndexStyle(::Type{<:AdjOrTransAbsMat}) = IndexCartesian()
Expand Down
9 changes: 8 additions & 1 deletion stdlib/LinearAlgebra/test/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ using Test, LinearAlgebra

const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")

isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl"))
using .Main.OffsetArrays

@testset "Adjoint and Transpose inner constructor basics" begin
intvec, intmat = [1, 2], [1 2; 3 4]
# Adjoint/Transpose eltype must match the type of the Adjoint/Transpose of the input eltype
Expand Down Expand Up @@ -87,11 +90,15 @@ end
@test size(Transpose(intvec)) == (1, length(intvec))
@test size(Transpose(intmat)) == reverse(size(intmat))
end
@testset "indices methods" begin
@testset "axes methods" begin
@test axes(Adjoint(intvec)) == (Base.OneTo(1), Base.OneTo(length(intvec)))
@test axes(Adjoint(intmat)) == reverse(axes(intmat))
@test axes(Transpose(intvec)) == (Base.OneTo(1), Base.OneTo(length(intvec)))
@test axes(Transpose(intmat)) == reverse(axes(intmat))

A = OffsetArray([1,2], 2)
@test (@inferred axes(A')[2]) === axes(A,1)
@test (@inferred axes(A')[1]) === axes(A,2)
end
@testset "IndexStyle methods" begin
@test IndexStyle(Adjoint(intvec)) == IndexLinear()
Expand Down