Skip to content

Commit

Permalink
Replace ind2sub by CartesianIndices (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Oct 31, 2023
1 parent a04de3d commit d44e944
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ function _getindex(::Type{Tuple{AA,BB}}, M::Mul, (k, j)::Tuple{AA,BB}) where {AA
end

# linear indexing
_getindex(::Type{NTuple{2,Int}}, M, k::Tuple{Int}) = M[Base._ind2sub(axes(M), k...)...]
function _getindex(::Type{NTuple{2,Int}}, M, k::Tuple{Int})
# convert from linear to CartesianIndex
CartInd = CartesianIndices(axes(M))[k...]
M[Tuple(CartInd)...]
end

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

2 comments on commit d44e944

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/94490

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.3 -m "<description of version>" d44e944e3621153f558e919fdeccf6d7c0604266
git push origin v1.4.3

Please sign in to comment.