Re: Matrix algebra and index order, A # B vs A ## B [message #79846 is a reply to message #79655] |
Thu, 05 April 2012 10:29   |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Kenneth P. Bowman:
> David Fanning:
>
>> Mats Löfdahl writes:
>>
>>> I'm writing some code where matrix algebra is at the heart of things so I
>>> really wanted to understand the conventions and convince myself that I can
>>> use them in a consistent way.
>
> The "Manipulating Arrays" section of the documentation is some help.
>
> As is so often the case with IDL, the ultimate solution to understanding
> how it actually works is to create a trivial example and make sure
> that you understand it.
>
> This is easier than trying to figure out row-major, column-major, etc.
>
> Such as
>
> IDL> a = FINDGEN(3,3)
> IDL> x = REPLICATE(1.0, 3)
> IDL> print, x
> 1.00000 1.00000 1.00000
> IDL> print, TRANSPOSE(a)
> 0.00000 3.00000 6.00000
> 1.00000 4.00000 7.00000
> 2.00000 5.00000 8.00000
> IDL> print, a#x
> 9.00000 12.0000 15.0000
> IDL> print, a
> 0.00000 1.00000 2.00000
> 3.00000 4.00000 5.00000
> 6.00000 7.00000 8.00000
> IDL> print, a##x
> 3.00000
> 12.0000
> 21.0000
I guess everybody has to understand various concepts in their own way. To me, your example just demonstrates one thing I tried to avoid: having to memorize when an array can be printed as it is and look like the matrix it is intended to represent and when it has to be transposed.
/Mats
|
|
|