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

Home » Public Forums » archive » really stupid matrix question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
really stupid matrix question [message #94830] Mon, 30 October 2017 10:49 Go to next message
astroboy.20000 is currently offline  astroboy.20000
Messages: 39
Registered: August 2012
Member
OK, before my head explodes, can anyone tell me the answer to this?

a=indgen(4,3)
print, a
0,1,2,3
4,5,6,7
8,9,10,11

OK, are the horizontal lines really vertical vectors? I think they would be based on idl being column-major, which means the columns are contiguous in memory. If. I. understand. correctly.

If this is correct, then why does IDL print them out in rows????

Someone please shoot me.
Re: really stupid matrix question [message #94834 is a reply to message #94830] Mon, 30 October 2017 12:46 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I have always has trouble remembering column-major and row-major (and thus never use the terms) so I hope I don't confuse things here. But from Wikipedia

https://en.wikipedia.org/wiki/Row-_and_column-major_order

"A general way to order objects with many attributes is to first group and order them by one attribute, and then, within each such group, group and order them by another attribute, etc. If more than one attribute participate in ordering, the *first* would be called major and the last minor."

In column major, you first order by column, and then say within column zero you order by rows. So in column major, the *rows* are contiguous in memory.

-Wayne

On Monday, October 30, 2017 at 1:49:27 PM UTC-4, Ann Nonymous wrote:
> OK, before my head explodes, can anyone tell me the answer to this?
>
> a=indgen(4,3)
> print, a
> 0,1,2,3
> 4,5,6,7
> 8,9,10,11
>
> OK, are the horizontal lines really vertical vectors? I think they would be based on idl being column-major, which means the columns are contiguous in memory. If. I. understand. correctly.
>
> If this is correct, then why does IDL print them out in rows????
>
> Someone please shoot me.
Re: really stupid matrix question [message #94835 is a reply to message #94830] Mon, 30 October 2017 13:15 Go to previous messageGo to next message
Burch is currently offline  Burch
Messages: 28
Registered: December 2013
Junior Member
On Monday, October 30, 2017 at 12:49:27 PM UTC-5, Ann Nonymous wrote:
> OK, before my head explodes, can anyone tell me the answer to this?
>
> a=indgen(4,3)
> print, a
> 0,1,2,3
> 4,5,6,7
> 8,9,10,11
>
> OK, are the horizontal lines really vertical vectors? I think they would be based on idl being column-major, which means the columns are contiguous in memory. If. I. understand. correctly.
>
> If this is correct, then why does IDL print them out in rows????
>
> Someone please shoot me.

In IDL the first dimension is stored contiguously in memory. When printing, this dimension corresponds to the column (this is how IDL maps it, some other languages map the first dimension to rows when printing/displaying). For your example, the elements are stored in memory in the order [0, 0], [1, 0], [2, 0], [3, 0], [0, 1], [1, 1], [2, 1], [3, 1], [0, 2], [1, 2], [2, 2], [3, 2].

Note that how the creators of a language choose to DISPLAY an array is NOT THE SAME as whether or not the language is described as row- or column-major, which is based strictly on the mathematical [row, column] notation (which is the opposite of how IDL displays it). You can read more about this, and why it's particularly confusing in IDL, here: http://www.harrisgeospatial.com/docs/Columns__Rows__and_Arra y.html

-Jeff
Re: really stupid matrix question [message #94836 is a reply to message #94835] Tue, 31 October 2017 10:45 Go to previous messageGo to next message
astroboy.20000 is currently offline  astroboy.20000
Messages: 39
Registered: August 2012
Member
Thanks for the help everyone. Please allow me another question:

x=findgen(5)

is x a column vector or a row vector? It prints out like its a row, of course, but I haven't found anything in the documentation that explicitly says which one it is. Saying that the first dimension is stored contiguously is a bit ambiguous.
Re: really stupid matrix question [message #94837 is a reply to message #94836] Tue, 31 October 2017 10:46 Go to previous messageGo to next message
astroboy.20000 is currently offline  astroboy.20000
Messages: 39
Registered: August 2012
Member
On Tuesday, October 31, 2017 at 1:45:33 PM UTC-4, Ann Nonymous wrote:
> Thanks for the help everyone. Please allow me another question:
>
> x=findgen(5)
>
> is x a column vector or a row vector? It prints out like its a row, of course, but I haven't found anything in the documentation that explicitly says which one it is. Saying that the first dimension is stored contiguously is a bit ambiguous.

I suppose it must be a row, since transpose(x) is clearly a column. Never mind. Thanks.
Re: really stupid matrix question [message #94838 is a reply to message #94837] Tue, 31 October 2017 12:51 Go to previous messageGo to next message
benjamin.castellani is currently offline  benjamin.castellani
Messages: 7
Registered: October 2017
Junior Member
The first dimension of any array/vector is column index in IDL.

x = findgen(5)

produces an array with 5 Columns and 1 (Implied) Row.

I always remember Matlab is (Row Index, Column Index)--> RC --> RC Cars (childhood toy). IDL is the opposite of Matlab. CR --> ???
Do you have a mnemonic device for this one?

On Tuesday, October 31, 2017 at 11:47:00 AM UTC-6, Ann Nonymous wrote:
> On Tuesday, October 31, 2017 at 1:45:33 PM UTC-4, Ann Nonymous wrote:
>> Thanks for the help everyone. Please allow me another question:
>>
>> x=findgen(5)
>>
>> is x a column vector or a row vector? It prints out like its a row, of course, but I haven't found anything in the documentation that explicitly says which one it is. Saying that the first dimension is stored contiguously is a bit ambiguous.
>
> I suppose it must be a row, since transpose(x) is clearly a column. Never mind. Thanks.
Re: really stupid matrix question [message #94840 is a reply to message #94838] Wed, 01 November 2017 15:32 Go to previous message
astroboy.20000 is currently offline  astroboy.20000
Messages: 39
Registered: August 2012
Member
On Tuesday, October 31, 2017 at 3:51:15 PM UTC-4, Ben Castellani wrote:
> The first dimension of any array/vector is column index in IDL.
>
> x = findgen(5)
>
> produces an array with 5 Columns and 1 (Implied) Row.
>
>
That makes sense, but I have to say its confusing that print,x prints everything on a single line, which of course makes it look like a row...... That's more convenient, of course.... Thanx!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: display direction
Next Topic: Re: harrisgeospatial unreachable...

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

Current Time: Wed Oct 08 09:20:47 PDT 2025

Total time taken to generate the page: 0.00484 seconds