# CuArrays.jl errors with indexing / CartesianIndices

**URL:** <https://discourse.julialang.org/t/cuarrays-jl-errors-with-indexing-cartesianindices/26416>\
**Category:** General Usage\
**Tags:** gpu, indexing, cuda\
**Created:** [July 16, 2019, 12:37pm UTC](https://discourse.julialang.org/t/cuarrays-jl-errors-with-indexing-cartesianindices/26416 "2019-07-16T12:37:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [July 16, 2019, 12:37pm UTC](https://discourse.julialang.org/t/cuarrays-jl-errors-with-indexing-cartesianindices/26416/1 "2019-07-16T12:37:17Z")

</div>

Hi,

I need to record the range of a subarray in a struct in order to define a padded-array.

However I have troubles using indexing in `CuArrays.jl`. Basically, the only solution which works is to use things like `u[1:10,1:10] .= v` but if I want to consider different array dimensions, I have to rewrite the code.

Am I missing a point?

If somebody can give a hint, I would be gratefull,

Thank you,

Bests.

```julia
using CuArrays
N = 100
CuArrays.allowscalar(false)
u = CuArrays.CuArray(rand(N,N))
v = CuArrays.CuArray(rand(10,10))
u[1:10,1:10] ;#OK
u[1:10,1:10] .= v ;#OK

rang = CartesianIndices((1:10,1:10))
u[rang]; #error
u[rang] .= v ;#error

rang = LinearIndices((1:10,1:10))
u[rang]; #OK
u[rang] .= v ;#error

rang = (1:10,1:10)
u[rang[1],rang[2]].=v; #works but what if I want to consider 3d arrays?

```

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [July 24, 2019, 5:18pm UTC](https://discourse.julialang.org/t/cuarrays-jl-errors-with-indexing-cartesianindices/26416/2 "2019-07-24T17:18:31Z")

</div>

> [@rveltz](#):
>
> rang = (1:10,1:10)

It seems the solution is use

```julia
rang = (1:10,1:10)
u[rang...] .=v;

```
