From f837e7b1fc0d9d31214677745fcb1864dbe47efa Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Mon, 23 Mar 2015 12:32:21 -0400 Subject: [PATCH] Remove getindex methods for Sparse, CHOLMOD.Dense --- base/sparse/cholmod.jl | 12 ++++-------- base/sparse/sparsematrix.jl | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index b39ca605dd495..14c416a049e11 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -1,6 +1,7 @@ module CHOLMOD -import Base: (*), convert, copy, eltype, getindex, show, size +import Base: (*), convert, copy, eltype, getindex, show, size, + linearindexing, LinearFast, LinearSlow import Base.LinAlg: (\), A_mul_Bc, A_mul_Bt, Ac_ldiv_B, Ac_mul_B, At_ldiv_B, At_mul_B, cholfact, cholfact!, det, diag, ishermitian, isposdef, @@ -916,19 +917,14 @@ function size(F::Factor, i::Integer) return 1 end +linearindexing(::Dense) = LinearFast() function getindex(A::Dense, i::Integer) s = unsafe_load(A.p) 0 < i <= s.nrow*s.ncol || throw(BoundsError()) unsafe_load(s.x, i) end -function getindex(A::Dense, i::Integer, j::Integer) - s = unsafe_load(A.p) - 0 < i <= s.nrow || throw(BoundsError()) - 0 < j <= s.ncol || throw(BoundsError()) - unsafe_load(s.x, i + (j - 1)*s.d) -end -getindex(A::Sparse, i::Integer) = getindex(A, ind2sub(size(A),i)...) +linearindexing(::Sparse) = LinearSlow() function getindex{T}(A::Sparse{T}, i0::Integer, i1::Integer) s = unsafe_load(A.p) !(1 <= i0 <= s.nrow && 1 <= i1 <= s.ncol) && throw(BoundsError()) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index 3f92e56ada533..dffe49aa2f6c1 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -1036,7 +1036,6 @@ function rangesearch(haystack::Range, needle) (rem==0 && 1<=i+1<=length(haystack)) ? i+1 : 0 end -getindex(A::SparseMatrixCSC, i::Integer) = getindex(A, ind2sub(size(A),i)) getindex(A::SparseMatrixCSC, I::(Integer,Integer)) = getindex(A, I[1], I[2]) function getindex{T}(A::SparseMatrixCSC{T}, i0::Integer, i1::Integer)