StructArrays.jl icon indicating copy to clipboard operation
StructArrays.jl copied to clipboard

how to set the i,j,k index for a multidimensional structarray ?

Open MKAbdElrahman opened this issue 4 years ago • 1 comments

Currently, to set the field values for the ijk struct, I convert first to linear indexing.

lh = LazyRow(h,i + Ny*(j-1) + Nx*Ny * (k-1));
					
setproperty!(lh,:x,hx)
setproperty!(lh,:y,hy)					
setproperty!(lh,:z,hz)		

I wonder if there is a direct way:

lh = LazyRow(h,(i,j,k));

setproperty!(lh,:x,hx)
setproperty!(lh,:y,hy)					
setproperty!(lh,:z,hz)

MKAbdElrahman avatar May 17 '21 12:05 MKAbdElrahman

Ah, LazyRow is actually a bit too low-level, because it assumes that the passed index type is the optimal one for the array you are using.

lh = LazyRows(t)[i, j, k]

is probably what you want. Keeping the issue open because the docs should probably get updated to make this clearer.

piever avatar May 18 '21 10:05 piever