comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » For loop avoidance - getting indices of real space
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
For loop avoidance - getting indices of real space [message #81163] Thu, 23 August 2012 13:58 Go to previous message
simulana is currently offline  simulana
Messages: 15
Registered: August 2012
Junior Member
I have read and re-read until cross-eyed this post: http://www.idlcoyote.com/tips/forloops.html

And yet, I still can't quite grasp at how I can solve my for loop problem. I think it might involve the use of modulo (MOD), but I'm not sure how. My question is, how can you grab the indices (i,j,k) of a 3D array in real space, and throw them into basically 3 1D arrays that is just a list of all the cells in the "proper" order (column-major).

Here is an example of what I mean:

pro testreader

xcells=15
ycells=10
zcells=20
ncells=xcells*ycells*zcells

data=dindgen(xcells,ycells,zcells)
coord=intarr(ncells,3)

index=0L
for k=0,zcells do begin
for j=0,ycells do begin
for i = 0,xcells do begin
coord(index,0)=i
coord(index,1)=j
coord(index,2)=k
index=index+1
endfor
endfor
endfor

end

This is a really simple version of a complex problem I have. I have sets of different size boxes from an AMR MHD code, and I need to keep track of their indices, but I just want a list of all of the cells, not to drag around a bunch of smaller arrays or try to concatenate them into one giant sparse array (waste of space). I'm certain that someone must have had this problem before, but I can't find any other suggestions on this forum.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Plot Size difference
Next Topic: Escaped Characters in string output

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:34:35 PDT 2025

Total time taken to generate the page: 0.00394 seconds