Skip to content

Commit ba365c1

Browse files
authored
Use layout_getindex for adjoint-LayoutVectors with range access (#265)
Before: ```julia-repl julia> using LazyArrays; v = ((1:10_000) .* LazyArrays.AccumulateAbstractVector(*, 1:10_000'))'; @time v[1:1, 1:10_000]; 0.031649 seconds (476.63 k allocations: 12.861 MiB) ``` After: ```julia-repl julia> using LazyArrays; v = ((1:10_000) .* LazyArrays.AccumulateAbstractVector(*, 1:10_000'))'; @time v[1:1, 1:10_000]; 0.000031 seconds (65 allocations: 2.156 KiB) ``` (Improved timings also require JuliaArrays/LazyArrays.jl#387)
1 parent e809d34 commit ba365c1

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "1.12.0"
4+
version = "1.12.1"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/ArrayLayouts.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ getindex(A::LayoutVector, kr::AbstractVector) = layout_getindex(A, kr)
204204
getindex(A::LayoutVector, kr::Colon) = layout_getindex(A, kr)
205205
getindex(A::AdjOrTrans{<:Any,<:LayoutVector}, kr::Integer, jr::Colon) = layout_getindex(A, kr, jr)
206206
getindex(A::AdjOrTrans{<:Any,<:LayoutVector}, kr::Integer, jr::AbstractVector) = layout_getindex(A, kr, jr)
207+
getindex(A::AdjOrTrans{<:Any,<:LayoutVector}, kr::AbstractVector, jr::AbstractVector) = layout_getindex(A, kr, jr)
207208

208209
*(a::Zeros{<:Any,2}, b::LayoutMatrix) = FillArrays.mult_zeros(a, b)
209210
*(a::LayoutMatrix, b::Zeros{<:Any,2}) = FillArrays.mult_zeros(a, b)

test/test_layoutarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Base.copy(A::MyVector) = MyVector(copy(A.A))
4949
@test a[1:3] == a.A[1:3]
5050
@test a[:] == a
5151
@test (a')[1,:] == (a')[1,1:3] == a
52+
@test (a')[1:1, :] == (a')[1:1,1:3] == a'
53+
@test (a')[1:1, 2:3] == (a')[1:1,2:3] == a[2:3]'
5254
@test sprint(show, "text/plain", a) == "$(summary(a)):\n 1.0\n 2.0\n 3.0"
5355
@test B*a B*a.A
5456
@test B'*a B'*a.A

0 commit comments

Comments
 (0)