Skip to content

Commit

Permalink
fix for 1d offset axes
Browse files Browse the repository at this point in the history
Update indexing.jl
  • Loading branch information
N5N3 committed Feb 21, 2022
1 parent 3fd8c29 commit ded0eaa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/device/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ macro linearidx(A, grididx=1, ctxsym=:ctx)
x = $(esc(A))
i = linear_index($(esc(ctxsym)), $(esc(grididx)))
i > length(x) && return
i
i + firstindex(x) - 1
end
end

Expand All @@ -77,7 +77,8 @@ Like [`@linearidx`](@ref), but returns a N-dimensional `CartesianIndex`.
macro cartesianidx(A, grididx=1, ctxsym=:ctx)
quote
x = $(esc(A))
i = @linearidx(x, $(esc(grididx)), $(esc(ctxsym)))
@inbounds CartesianIndices(x)[i]
cx = CartesianIndices(x)
i = @linearidx(cx, $(esc(grididx)), $(esc(ctxsym)))
@inbounds cx[i]
end
end

0 comments on commit ded0eaa

Please sign in to comment.