If you need to write your own loop, IDL has all the standard loop types such as FOR and WHILE, etc. However, when operating on arrays in IDL, you should only use a loop if it is absolutely necessary because it will be much slower than using the array operators, #, ##, etc. directly. This is because operators such as #, and ## are multi-threaded and will take advantage of multiple cores on your CPU. By contrast, a FOR loop will not be multi threaded.
However, if you have a special case that requires looping, it would look something like this:
for i=0, 9 do begin ; row
for j=0, 9 do begin ;column
myarray[j, i] = 42 ; or whatever operation you need
endfor
endfor
As an example, to take advantage of multi threaded operations in the example above, the whole loop can be condensed to just one line of code which would accomplish the same thing much faster:
myarray[*] = 42
-Josh
Exelis VIS
|