StructArrays.jl
StructArrays.jl copied to clipboard
how to set the i,j,k index for a multidimensional structarray ?
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)
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.