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

Home » Public Forums » archive » Re: Assignment Time for a 3d Variable
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Assignment Time for a 3d Variable [message #46459] Wed, 23 November 2005 12:17 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
F�ldy Lajos wrote:
> Hi,
>
> Fortran is column major, IDL and C are row major. In IDL (unlike C or
> Fortran) the first subscript is column, not row.
>
> It is best not to refer to Fortran or C, IDL is like IDL :-)

Dragging in "rows" and "columns" here is a distraction. They relate
(presumably) to how you print an array or possibly to how you interpret
the array dimensions in matrix operations. I am not really a
matrix-oriented guy and that is why I find Matlab so painful. It also
may be why when I hear people use the terms row-major and column-major I
put my fingers in my ears and go "la la la" until the noise stops.

IDL is like Fortran in that the left-most index refers to the dimension
that varies fastest in memory. Ie. if we have a = fltarr(3,2) then the
order of the elements in memory is...

a[0,0] a[1,0] a[2,0] a[0,1] a[1,1] a[2,1]

So it generally makes sense to loop over the left-most index (inner
dimension)

a = fltarr(m, n)
for j=0,n-1 do begin
for i=0,m-1 do begin
; Do something with a[i,j]
endfor
endfor

This way you're stepping thru memory from right to left.

Previous messages have suggested that because IDL is implemented in C it
must use C's convention. Not so.

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Creating Panels in iTools
Next Topic: How should I mark annotations in multi plot window

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

Current Time: Wed Oct 08 15:07:06 PDT 2025

Total time taken to generate the page: 0.00438 seconds