diff --git a/src/indexing.jl b/src/indexing.jl index 80563e18..4025bf40 100644 --- a/src/indexing.jl +++ b/src/indexing.jl @@ -13,31 +13,6 @@ end end -# Tuple indexing into AbstractArray. TODO, move into base -@generated function getindex{S}(a::AbstractArray, inds::NTuple{S,Integer}) - exprs = [:(a[inds[$i]]) for i = 1:S] - return quote - $(Expr(:meta, :inline, :propagate_inbounds)) - return $(Expr(:tuple, exprs...)) - end -end -# Convert to StaticArrays using tuples -# TODO think about bounds checks here. -@generated function getindex{S,T}(m::AbstractArray{T}, inds1::NTuple{S, Integer}, i2::Integer) - exprs = [:(m[inds1[$j], i2]) for j = 1:S] - return Expr(:tuple, exprs...) -end - -@generated function getindex{S,T}(m::AbstractArray{T}, i1::Integer, inds2::NTuple{S, Integer}) - exprs = [:(m[i1, inds2[$j]]) for j = 1:S] - return Expr(:tuple, exprs...) -end - -@generated function getindex{S1,S2,T}(m::AbstractArray{T}, inds1::NTuple{S1, Integer}, inds2::NTuple{S2, Integer}) - exprs = [:(m[inds1[$j1], inds2[$j2]]) for j1 = 1:S1, j2 = 1:S2] - return Expr(:call, SMatrix{S1,S2,T}, Expr(:tuple, exprs...)) # TODO decision: return tuple? Leave it? -end - # Static Vector indexing into AbstractArrays @generated function getindex{T, I <: Integer}( a::AbstractArray{T}, inds::StaticVector{I} diff --git a/test/indexing.jl b/test/indexing.jl index 9548fa92..d2b70a30 100644 --- a/test/indexing.jl +++ b/test/indexing.jl @@ -23,13 +23,8 @@ @testset "Linear getindex()/setindex!() with a SVector on an Array" begin v = [11,12,13] - m = [1.0 2.0; 3.0 4.0] - - @test v[(2,3)] === (12, 13) - @test m[(2,3)] === (3.0, 2.0) @test (v[SVector(2,3)] = [22,23]; (v[2] == 22) & (v[3] == 23)) - end @testset "2D getindex() on SMatrix" begin @@ -70,14 +65,6 @@ @test (mm = MMatrix{2,2,Int}(); mm[:,1] = sm[:,1]; (@inferred getindex(mm, :, 1))::MVector == @MVector [1,2]) end - @testset "2D getindex() with tuples on an Array" begin - m = [1.0 2.0; 3.0 4.0] - - @test m[(1,2), (1,2)] === @SMatrix [1.0 2.0; 3.0 4.0] - @test m[1, (1,2)] === (1.0, 2.0) - @test m[(1,2), 1] === (1.0, 3.0) - end - @testset "3D scalar indexing" begin sa = SArray{(2,2,2), Int}([i*j*k for i = 1:2, j = 2:3, k=3:4])