Skip to content

Commit 4c81c3b

Browse files
committed
Ensure that ArrayLS and ArrayLSLS really are LinearSlow
1 parent d5689b5 commit 4c81c3b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/array/sumindex.jl

+10-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ Base.similar{T}(A::ArrayLSLS, ::Type{T}, dims::Tuple{Vararg{Int}}) = ArrayLSLS(s
155155

156156
Base.first(A::ArrayLSLS) = first(A.data)
157157

158-
Base.size(A::MyArray) = size(A.data)
158+
Base.size{T}(A::MyArray{T,2}) = size(A.data)
159+
# To ensure that ArrayLS and ArrayLSLS really are LinearSlow even
160+
# after inlining, let's make the size differ from the parent array
161+
# (ref https://github.com/JuliaLang/julia/pull/17355#issuecomment-231748251)
162+
Base.size{T}(A::ArrayLS{T,2}) = (sz = size(A.data); (sz[1]-1,sz[2]-1))
163+
Base.size{T}(A::ArrayLSLS{T,2}) = (sz = size(A.data); (sz[1]-1,sz[2]-1))
159164

160165
@inline Base.getindex(A::ArrayLF, i::Int) = getindex(A.data, i)
161166
@inline Base.getindex(A::ArrayLF, i::Int, i2::Int) = getindex(A.data, i, i2)
@@ -181,8 +186,10 @@ end
181186

182187
function makearrays{T}(::Type{T}, r::Integer, c::Integer)
183188
A = samerand(T, r, c)
184-
AS = ArrayLS(A)
185-
ASS = ArrayLSLS(A)
189+
B = similar(A, r+1, c+1)
190+
B[1:r, 1:c] = A
191+
AS = ArrayLS(B)
192+
ASS = ArrayLSLS(B)
186193
AF = ArrayLF(A)
187194
Astrd = ArrayStrides(A)
188195
Astrd1 = ArrayStrides1(A)

0 commit comments

Comments
 (0)