Skip to content
Browse files

make Base array methods more specific using StoredArray and DenseArray.

closes #987

also remove some BitArray methods that used bitunpack, since BitArray
is now a DenseArray

make reshape() to the same size a no-op for Array and BitArray

remove a couple other redundant definitions
  • Loading branch information...
1 parent 7853848 commit c330b1d64efa566911cdd20921ca9419e58bacf9 @JeffBezanson JeffBezanson committed Feb 20, 2014
Showing with 157 additions and 175 deletions.
  1. +10 −126 base/abstractarray.jl
  2. +136 −19 base/array.jl
  3. +4 −14 base/bitarray.jl
  4. +1 −1 base/darray.jl
  5. +0 −5 base/linalg/bitarray.jl
  6. +2 −2 base/linalg/matmul.jl
  7. +2 −2 base/multidimensional.jl
  8. +1 −2 base/sparse/abstractsparse.jl
  9. +1 −4 base/subarray.jl
View
136 base/abstractarray.jl
@@ -163,7 +163,7 @@ function squeeze(A::AbstractArray, dims)
reshape(A, d)
end
-function copy!(dest::AbstractArray, src)
+function copy!(dest::StoredArray, src)
i = 1
for x in src
dest[i] = x
@@ -174,7 +174,7 @@ end
# copy with minimal requirements on src
# if src is not an AbstractArray, moving to the offset might be O(n)
-function copy!(dest::AbstractArray, doffs::Integer, src, soffs::Integer=1)
+function copy!(dest::StoredArray, doffs::Integer, src, soffs::Integer=1)
st = start(src)
for j = 1:(soffs-1)
_, st = next(src, st)
@@ -191,13 +191,13 @@ end
# NOTE: this is to avoid ambiguity with the deprecation of
# copy!(dest::AbstractArray, src, doffs::Integer)
# Remove this when that deprecation is removed.
-function copy!(dest::AbstractArray, doffs::Integer, src::Integer)
+function copy!(dest::StoredArray, doffs::Integer, src::Integer)
dest[doffs] = src
return dest
end
# this method must be separate from the above since src might not have a length
-function copy!(dest::AbstractArray, doffs::Integer, src, soffs::Integer, n::Integer)
+function copy!(dest::StoredArray, doffs::Integer, src, soffs::Integer, n::Integer)
n == 0 && return dest
st = start(src)
for j = 1:(soffs-1)
@@ -212,7 +212,7 @@ function copy!(dest::AbstractArray, doffs::Integer, src, soffs::Integer, n::Inte
end
# if src is an AbstractArray and a source offset is passed, use indexing
-function copy!(dest::AbstractArray, doffs::Integer, src::AbstractArray, soffs::Integer, n::Integer=length(src))
+function copy!(dest::StoredArray, doffs::Integer, src::AbstractArray, soffs::Integer, n::Integer=length(src))
for i = 0:(n-1)
dest[doffs+i] = src[soffs+i]
end
@@ -249,7 +249,7 @@ for (f,t) in ((:char, Char),
@eval begin
($f)(x::AbstractArray{$t}) = x
- function ($f)(x::AbstractArray)
+ function ($f)(x::StoredArray)
y = similar(x,$t)
i = 1
for e in x
@@ -266,7 +266,7 @@ for (f,t) in ((:integer, Integer),
@eval begin
($f){T<:$t}(x::AbstractArray{T}) = x
- function ($f)(x::AbstractArray)
+ function ($f)(x::StoredArray)
y = similar(x,typeof(($f)(one(eltype(x)))))
i = 1
for e in x
@@ -312,9 +312,7 @@ end
conj{T<:Real}(x::AbstractArray{T}) = x
conj!{T<:Real}(x::AbstractArray{T}) = x
-real{T<:Real}(x::AbstractVector{T}) = x
real{T<:Real}(x::AbstractArray{T}) = x
-imag{T<:Real}(x::AbstractVector{T}) = zero(x)
imag{T<:Real}(x::AbstractArray{T}) = zero(x)
+{T<:Number}(x::AbstractArray{T}) = x
@@ -356,20 +354,6 @@ end
slicedim(A::AbstractArray, d::Integer, i) =
A[[ n==d ? i : (1:size(A,n)) for n in 1:ndims(A) ]...]
-function reverse(A::AbstractVector, s=1, n=length(A))
- B = similar(A)
- for i = 1:s-1
- B[i] = A[i]
- end
- for i = s:n
- B[i] = A[n+s-i]
- end
- for i = n+1:length(A)
- B[i] = A[i]
- end
- B
-end
-
function flipdim(A::AbstractVector, d::Integer)
d > 0 || error("dimension to flip must be positive")
d == 1 || return copy(A)
@@ -857,106 +841,6 @@ function (==)(A::AbstractArray, B::AbstractArray)
return true
end
-_cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T))
-_cumsum_type(v) = typeof(v[1]+v[1])
-
-for (f, fp, op) = ((:cumsum, :cumsum_pairwise, :+),
- (:cumprod, :cumprod_pairwise, :*) )
- # in-place cumsum of c = s+v(i1:n), using pairwise summation as for sum
- @eval function ($fp)(v::AbstractVector, c::AbstractVector, s, i1, n)
- if n < 128
- @inbounds c[i1] = ($op)(s, v[i1])
- for i = i1+1:i1+n-1
- @inbounds c[i] = $(op)(c[i-1], v[i])
- end
- else
- n2 = div(n,2)
- ($fp)(v, c, s, i1, n2)
- ($fp)(v, c, c[(i1+n2)-1], i1+n2, n-n2)
- end
- end
-
- @eval function ($f)(v::AbstractVector)
- n = length(v)
- c = $(op===:+ ? (:(similar(v,_cumsum_type(v)))) :
- (:(similar(v))))
- if n == 0; return c; end
- ($fp)(v, c, $(op==:+ ? :(zero(v[1])) : :(one(v[1]))), 1, n)
- return c
- end
-
- @eval function ($f)(A::AbstractArray, axis::Integer)
- dimsA = size(A)
- ndimsA = ndims(A)
- axis_size = dimsA[axis]
- axis_stride = 1
- for i = 1:(axis-1)
- axis_stride *= size(A,i)
- end
-
- B = $(op===:+ ? (:(similar(A,_cumsum_type(A)))) :
- (:(similar(A))))
-
- if axis_size < 1
- return B
- end
-
- for i = 1:length(A)
- if div(i-1, axis_stride) % axis_size == 0
- B[i] = A[i]
- else
- B[i] = ($op)(B[i-axis_stride], A[i])
- end
- end
-
- return B
- end
-
- @eval ($f)(A::AbstractArray) = ($f)(A, 1)
-end
-
-for (f, op) = ((:cummin, :min), (:cummax, :max))
- @eval function ($f)(v::AbstractVector)
- n = length(v)
- cur_val = v[1]
- res = similar(v, n)
- res[1] = cur_val
- for i in 2:n
- cur_val = ($op)(v[i], cur_val)
- res[i] = cur_val
- end
- return res
- end
-
- @eval function ($f)(A::AbstractArray, axis::Integer)
- dimsA = size(A)
- ndimsA = ndims(A)
- axis_size = dimsA[axis]
- axis_stride = 1
- for i = 1:(axis-1)
- axis_stride *= size(A,i)
- end
-
- if axis_size < 1
- return A
- end
-
- B = similar(A)
-
- for i = 1:length(A)
- if div(i-1, axis_stride) % axis_size == 0
- B[i] = A[i]
- else
- B[i] = ($op)(A[i], B[i-axis_stride])
- end
- end
-
- return B
- end
-
- @eval ($f)(A::AbstractArray) = ($f)(A, 1)
-end
-
# Uses K-B-N summation
function cumsum_kbn{T<:FloatingPoint}(v::AbstractVector{T})
n = length(v)
@@ -1347,7 +1231,7 @@ end
## 1 argument
-function map_to!(f::Callable, first, dest::AbstractArray, A::AbstractArray)
+function map_to!(f::Callable, first, dest::StoredArray, A::AbstractArray)
dest[1] = first
for i=2:length(A)
dest[i] = f(A[i])
@@ -1363,7 +1247,7 @@ function map(f::Callable, A::AbstractArray)
end
## 2 argument
-function map_to!(f::Callable, first, dest::AbstractArray, A::AbstractArray, B::AbstractArray)
+function map_to!(f::Callable, first, dest::StoredArray, A::AbstractArray, B::AbstractArray)
dest[1] = first
for i=2:length(A)
dest[i] = f(A[i], B[i])
@@ -1382,7 +1266,7 @@ function map(f::Callable, A::AbstractArray, B::AbstractArray)
end
## N argument
-function map_to!(f::Callable, first, dest::AbstractArray, As::AbstractArray...)
+function map_to!(f::Callable, first, dest::StoredArray, As::AbstractArray...)
n = length(As[1])
i = 1
ith = a->a[i]
View
155 base/array.jl
@@ -4,6 +4,7 @@ typealias Vector{T} Array{T,1}
typealias Matrix{T} Array{T,2}
typealias VecOrMat{T} Union(Vector{T}, Matrix{T})
+typealias StoredVector{T} StoredArray{T,1}
typealias StridedArray{T,N,A<:DenseArray} Union(DenseArray{T,N}, SubArray{T,N,A})
typealias StridedVector{T,A<:DenseArray} Union(DenseArray{T,1}, SubArray{T,1,A})
typealias StridedMatrix{T,A<:DenseArray} Union(DenseArray{T,2}, SubArray{T,2,A})
@@ -81,7 +82,7 @@ function copy!{R,S}(B::Matrix{R}, ir_dest::Range1{Int}, jr_dest::Range1{Int}, A:
end
end
-function copy_transpose!{R,S}(B::Matrix{R}, ir_dest::Range1{Int}, jr_dest::Range1{Int}, A::StridedMatrix{S}, ir_src::Range1{Int}, jr_src::Range1{Int})
+function copy_transpose!{R,S}(B::Matrix{R}, ir_dest::Range1{Int}, jr_dest::Range1{Int}, A::StridedVecOrMat{S}, ir_src::Range1{Int}, jr_src::Range1{Int})
if length(ir_dest) != length(jr_src) || length(jr_dest) != length(ir_src)
error("source and destination must have same size")
end
@@ -131,6 +132,9 @@ function reshape{T,N}(a::Array{T}, dims::NTuple{N,Int})
if prod(dims) != length(a)
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(length(a))"))
end
+ if dims == size(a)
+ return a
+ end
ccall(:jl_reshape_array, Array{T,N}, (Any, Any, Any), Array{T,N}, a, dims)
end
@@ -681,7 +685,7 @@ end
## Unary operators ##
-function conj!{T<:Number}(A::AbstractArray{T})
+function conj!{T<:Number}(A::StoredArray{T})
for i=1:length(A)
A[i] = conj(A[i])
end
@@ -690,7 +694,7 @@ end
for f in (:-, :~, :conj, :sign)
@eval begin
- function ($f)(A::AbstractArray)
+ function ($f)(A::StridedArray)
F = similar(A)
for i=1:length(A)
F[i] = ($f)(A[i])
@@ -702,14 +706,12 @@ end
(-)(A::StridedArray{Bool}) = reshape([ -A[i] for i=1:length(A) ], size(A))
-for f in (:real, :imag)
- @eval begin
- ($f)(A::AbstractVector) = [ ($f)(x) for x in A ]
- ($f)(A::AbstractArray) = reshape([ ($f)(x) for x in A ], size(A))
- end
-end
+real(A::StridedArray) = reshape([ real(x) for x in A ], size(A))
+imag(A::StridedArray) = reshape([ imag(x) for x in A ], size(A))
+real{T<:Real}(x::StridedArray{T}) = x
+imag{T<:Real}(x::StridedArray{T}) = zero(x)
-function !(A::AbstractArray{Bool})
+function !(A::StridedArray{Bool})
F = similar(A)
for i=1:length(A)
F[i] = !A[i]
@@ -940,23 +942,23 @@ function flipdim{T}(A::Array{T}, d::Integer)
return B
end
-function rotl90(A::AbstractMatrix)
+function rotl90(A::StridedMatrix)
m,n = size(A)
B = similar(A,(n,m))
for i=1:m, j=1:n
B[n-j+1,i] = A[i,j]
end
return B
end
-function rotr90(A::AbstractMatrix)
+function rotr90(A::StridedMatrix)
m,n = size(A)
B = similar(A,(n,m))
for i=1:m, j=1:n
B[j,m-i+1] = A[i,j]
end
return B
end
-function rot180(A::AbstractMatrix)
+function rot180(A::StridedMatrix)
m,n = size(A)
B = similar(A)
for i=1:m, j=1:n
@@ -973,9 +975,24 @@ end
rotr90(A::AbstractMatrix, k::Integer) = rotl90(A,-k)
rot180(A::AbstractMatrix, k::Integer) = mod(k, 2) == 1 ? rot180(A) : copy(A)
+# note: probably should be StridedVector or StoredVector
+function reverse(A::AbstractVector, s=1, n=length(A))
+ B = similar(A)
+ for i = 1:s-1
+ B[i] = A[i]
+ end
+ for i = s:n
+ B[i] = A[n+s-i]
+ end
+ for i = n+1:length(A)
+ B[i] = A[i]
+ end
+ B
+end
+
reverse(v::StridedVector) = (n=length(v); [ v[n-i+1] for i=1:n ])
reverse(v::StridedVector, s, n=length(v)) = reverse!(copy(v), s, n)
-function reverse!(v::AbstractVector, s=1, n=length(v))
+function reverse!(v::StridedVector, s=1, n=length(v))
r = n
for i=s:div(s+n-1,2)
v[i], v[r] = v[r], v[i]
@@ -1041,7 +1058,7 @@ function findnext(testf::Function, A, start::Integer)
end
findfirst(testf::Function, A) = findnext(testf, A, 1)
-function find(testf::Function, A::AbstractArray)
+function find(testf::Function, A::StridedArray)
# use a dynamic-length array to store the indexes, then copy to a non-padded
# array for the return
tmpI = Array(Int, 0)
@@ -1055,7 +1072,7 @@ function find(testf::Function, A::AbstractArray)
I
end
-function find(A::AbstractArray)
+function find(A::StridedArray)
nnzA = countnz(A)
I = Array(Int, nnzA)
count = 1
@@ -1073,7 +1090,7 @@ find(testf::Function, x) = find(testf(x))
findn(A::AbstractVector) = find(A)
-function findn(A::AbstractMatrix)
+function findn(A::StridedMatrix)
nnzA = countnz(A)
I = Array(Int, nnzA)
J = Array(Int, nnzA)
@@ -1088,7 +1105,7 @@ function findn(A::AbstractMatrix)
return (I, J)
end
-function findnz{T}(A::AbstractMatrix{T})
+function findnz{T}(A::StridedMatrix{T})
nnzA = countnz(A)
I = zeros(Int, nnzA)
J = zeros(Int, nnzA)
@@ -1108,7 +1125,7 @@ function findnz{T}(A::AbstractMatrix{T})
return (I, J, NZs)
end
-function nonzeros{T}(A::AbstractArray{T})
+function nonzeros{T}(A::StridedArray{T})
nnzA = countnz(A)
V = Array(T, nnzA)
count = 1
@@ -1349,3 +1366,103 @@ end
symdiff(a) = a
symdiff(a, b) = union(setdiff(a,b), setdiff(b,a))
symdiff(a, b, rest...) = symdiff(a, symdiff(b, rest...))
+
+_cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T))
+_cumsum_type(v) = typeof(v[1]+v[1])
+
+for (f, fp, op) = ((:cumsum, :cumsum_pairwise, :+),
+ (:cumprod, :cumprod_pairwise, :*) )
+ # in-place cumsum of c = s+v(i1:n), using pairwise summation as for sum
+ @eval function ($fp)(v::StoredVector, c::StoredVector, s, i1, n)
+ if n < 128
+ @inbounds c[i1] = ($op)(s, v[i1])
+ for i = i1+1:i1+n-1
+ @inbounds c[i] = $(op)(c[i-1], v[i])
+ end
+ else
+ n2 = div(n,2)
+ ($fp)(v, c, s, i1, n2)
+ ($fp)(v, c, c[(i1+n2)-1], i1+n2, n-n2)
+ end
+ end
+
+ @eval function ($f)(v::StoredVector)
+ n = length(v)
+ c = $(op===:+ ? (:(similar(v,_cumsum_type(v)))) :
+ (:(similar(v))))
+ if n == 0; return c; end
+ ($fp)(v, c, $(op==:+ ? :(zero(v[1])) : :(one(v[1]))), 1, n)
+ return c
+ end
+
+ @eval function ($f)(A::StridedArray, axis::Integer)
+ dimsA = size(A)
+ ndimsA = ndims(A)
+ axis_size = dimsA[axis]
+ axis_stride = 1
+ for i = 1:(axis-1)
+ axis_stride *= size(A,i)
+ end
+
+ B = $(op===:+ ? (:(similar(A,_cumsum_type(A)))) :
+ (:(similar(A))))
+
+ if axis_size < 1
+ return B
+ end
+
+ for i = 1:length(A)
+ if div(i-1, axis_stride) % axis_size == 0
+ B[i] = A[i]
+ else
+ B[i] = ($op)(B[i-axis_stride], A[i])
+ end
+ end
+
+ return B
+ end
+
+ @eval ($f)(A::AbstractArray) = ($f)(A, 1)
+end
+
+for (f, op) = ((:cummin, :min), (:cummax, :max))
+ @eval function ($f)(v::StoredVector)
+ n = length(v)
+ cur_val = v[1]
+ res = similar(v, n)
+ res[1] = cur_val
+ for i in 2:n
+ cur_val = ($op)(v[i], cur_val)
+ res[i] = cur_val
+ end
+ return res
+ end
+
+ @eval function ($f)(A::StridedArray, axis::Integer)
+ dimsA = size(A)
+ ndimsA = ndims(A)
+ axis_size = dimsA[axis]
+ axis_stride = 1
+ for i = 1:(axis-1)
+ axis_stride *= size(A,i)
+ end
+
+ if axis_size < 1
+ return A
+ end
+
+ B = similar(A)
+
+ for i = 1:length(A)
+ if div(i-1, axis_stride) % axis_size == 0
+ B[i] = A[i]
+ else
+ B[i] = ($op)(A[i], B[i-axis_stride])
+ end
+ end
+
+ return B
+ end
+
+ @eval ($f)(A::AbstractArray) = ($f)(A, 1)
+end
View
18 base/bitarray.jl
@@ -13,7 +13,7 @@ const bitcache_size = 64 * bitcache_chunks # do not change this
# notes: bits are stored in contiguous chunks
# unused bits must always be set to 0
-type BitArray{N} <: AbstractArray{Bool, N}
+type BitArray{N} <: DenseArray{Bool, N}
chunks::Vector{Uint64}
len::Int
dims::NTuple{N,Int}
@@ -263,6 +263,9 @@ function reshape{N}(B::BitArray, dims::NTuple{N,Int})
if prod(dims) != length(B)
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(length(B))"))
end
+ if dims == size(B)
+ return B
+ end
Br = BitArray{N}(ntuple(N,i->0)...)
Br.chunks = B.chunks
Br.len = prod(dims)
@@ -908,12 +911,6 @@ function (./)(A::BitArray, B::BitArray)
shp = promote_shape(size(A),size(B))
reshape([ A[i] ./ B[i] for i=1:length(A) ], shp)
end
-function (./)(B::BitArray, x::Number)
- reshape([ B[i] ./ x for i = 1:length(B) ], size(B))
-end
-function (./)(x::Number, B::BitArray)
- reshape([ x ./ B[i] for i = 1:length(B) ], size(B))
-end
for f in (:/, :\)
@eval begin
@@ -1134,13 +1131,6 @@ end
(.*)(x::Number, B::BitArray) = x .* bitunpack(B)
(.*)(B::BitArray, x::Number) = bitunpack(B) .* x
-for f in (:+, :-, :div, :mod, :./, :.^, :.*, :&, :|, :$)
- @eval begin
- ($f)(A::BitArray, B::AbstractArray) = ($f)(bitunpack(A), B)
- ($f)(A::AbstractArray, B::BitArray) = ($f)(A, bitunpack(B))
- end
-end
-
## promotion to complex ##
# TODO?
View
2 base/darray.jl
@@ -1,4 +1,4 @@
-type DArray{T,N,A} <: AbstractArray{T,N}
+type DArray{T,N,A} <: StoredArray{T,N}
dims::NTuple{N,Int}
chunks::Array{RemoteRef,N}
View
5 base/linalg/bitarray.jl
@@ -64,11 +64,6 @@ function tril(B::BitMatrix, k::Integer)
A
end
-# TODO: improve this!
-(*)(A::BitArray, B::BitArray) = bitunpack(A) * bitunpack(B)
-(*)(A::BitArray, B::Union(AbstractArray, Array{Bool})) = bitunpack(A) * B
-(*)(A::Union(AbstractArray, Array{Bool}), B::BitArray) = A * bitunpack(B)
-
## diff and gradient
# TODO: this could be improved (is it worth it?)
View
4 base/linalg/matmul.jl
@@ -249,7 +249,7 @@ function copy!{R,S}(B::Matrix{R}, ir_dest::Range1{Int}, jr_dest::Range1{Int}, tM
end
end
-function copy_transpose!{R,S}(B::Matrix{R}, ir_dest::Range1{Int}, jr_dest::Range1{Int}, tM::Char, M::StridedMatrix{S}, ir_src::Range1{Int}, jr_src::Range1{Int})
+function copy_transpose!{R,S}(B::Matrix{R}, ir_dest::Range1{Int}, jr_dest::Range1{Int}, tM::Char, M::StridedVecOrMat{S}, ir_src::Range1{Int}, jr_src::Range1{Int})
if tM == 'N'
Base.copy_transpose!(B, ir_dest, jr_dest, M, ir_src, jr_src)
else
@@ -313,7 +313,7 @@ function generic_matvecmul{T,S,R}(C::StridedVector{R}, tA, A::StridedMatrix{T},
C
end
-(*){T,S}(A::Vector{S}, B::Matrix{T}) = reshape(A,length(A),1)*B
+(*){T,S}(A::AbstractVector{S}, B::AbstractMatrix{T}) = reshape(A,length(A),1)*B
# NOTE: the generic version is also called as fallback for strides != 1 cases
# in libalg_blas.jl
View
4 base/multidimensional.jl
@@ -131,14 +131,14 @@ eval(ngenerate(:N, nothing, :(setindex!{T}(s::SubArray{T,N}, v, ind::Integer)),
### from abstractarray.jl
-@ngenerate N typeof(A) function fill!{T,N}(A::AbstractArray{T,N}, x)
+@ngenerate N typeof(A) function fill!{T,N}(A::StoredArray{T,N}, x)
@nloops N i A begin
@inbounds (@nref N A i) = x
end
A
end
-@ngenerate N typeof(dest) function copy!{T,N}(dest::AbstractArray{T,N}, src::AbstractArray{T,N})
+@ngenerate N typeof(dest) function copy!{T,N}(dest::StoredArray{T,N}, src::StoredArray{T,N})
if @nall N d->(size(dest,d) == size(src,d))
@nloops N i dest begin
@inbounds (@nref N dest i) = (@nref N src i)
View
3 base/sparse/abstractsparse.jl
@@ -1,7 +1,6 @@
-abstract AbstractSparseMatrix{Tv,Ti} <: AbstractMatrix{Tv}
+abstract AbstractSparseMatrix{Tv,Ti} <: StoredArray{Tv,2}
issparse(A::AbstractArray) = false
issparse(S::AbstractSparseMatrix) = true
-eltype{Tv}(S::AbstractSparseMatrix{Tv}) = Tv
indtype{Tv,Ti}(S::AbstractSparseMatrix{Tv,Ti}) = Ti
View
5 base/subarray.jl
@@ -2,7 +2,7 @@
typealias RangeIndex Union(Int, Range{Int}, Range1{Int})
-type SubArray{T,N,A<:AbstractArray,I<:(RangeIndex...,)} <: AbstractArray{T,N}
+type SubArray{T,N,A<:StoredArray,I<:(RangeIndex...,)} <: StoredArray{T,N}
parent::A
indexes::I
dims::NTuple{N,Int}
@@ -188,7 +188,6 @@ parentindexes(a::AbstractArray) = ntuple(ndims(a), i->1:size(a,i))
copy(s::SubArray) = copy!(similar(s.parent, size(s)), s)
similar(s::SubArray, T, dims::Dims) = similar(s.parent, T, dims)
-getindex{T}(s::SubArray{T,0,AbstractArray{T,0}}) = s.parent[]
getindex{T}(s::SubArray{T,0}) = s.parent[s.first_index]
getindex{T}(s::SubArray{T,1}, i::Integer) =
@@ -355,8 +354,6 @@ function setindex!(s::SubArray, v, is::Integer...)
return s
end
-setindex!{T}(s::SubArray{T,0,AbstractArray{T,0}},v) = setindex!(s.parent, v)
-
setindex!{T}(s::SubArray{T,0}, v) = setindex!(s.parent, v, s.first_index)

0 comments on commit c330b1d

Please sign in to comment.
Something went wrong with that request. Please try again.