Skip to content

Commit ded0eaa

Browse files
committed
fix for 1d offset axes
Update indexing.jl
1 parent 3fd8c29 commit ded0eaa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/device/indexing.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ macro linearidx(A, grididx=1, ctxsym=:ctx)
6565
x = $(esc(A))
6666
i = linear_index($(esc(ctxsym)), $(esc(grididx)))
6767
i > length(x) && return
68-
i
68+
i + firstindex(x) - 1
6969
end
7070
end
7171

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

0 commit comments

Comments
 (0)