Skip to content

Commit d44e944

Browse files
authored
Replace ind2sub by CartesianIndices (#177)
1 parent a04de3d commit d44e944

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mul.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ function _getindex(::Type{Tuple{AA,BB}}, M::Mul, (k, j)::Tuple{AA,BB}) where {AA
5353
end
5454

5555
# linear indexing
56-
_getindex(::Type{NTuple{2,Int}}, M, k::Tuple{Int}) = M[Base._ind2sub(axes(M), k...)...]
56+
function _getindex(::Type{NTuple{2,Int}}, M, k::Tuple{Int})
57+
# convert from linear to CartesianIndex
58+
CartInd = CartesianIndices(axes(M))[k...]
59+
M[Tuple(CartInd)...]
60+
end
5761

5862
_getindex(::Type{Tuple{Int}}, M, (k,)::Tuple{CartesianIndex{1}}) = M[convert(Int, k)]
5963
_getindex(::Type{NTuple{2,Int}}, M, (kj,)::Tuple{CartesianIndex{2}}) = M[kj[1], kj[2]]

0 commit comments

Comments
 (0)