I don’t find PDL’s matrix handling to be screwy. There’s a necessary wart
between column-major addressing and row-major addressing, sure — but that’s
endemic to all languages. The question is whether you want matrices to
_naturally_render_ the way they would appear in mathematical notation, or
whether you want them to _naturally index_ the way they would appear in
mathematical notation. Some languages (e.g., IDL) chose the latter; others
(e.g., PDL) chose the former. You can’t have both without breaking the way
arrays are rendered on-screen (so that, e.g., “$a = pdl(1,2,3)” would render as
a column vector, taking 5 lines of text.
As it stands now, “print ($vec=pdl([1,5]))” yields “[1 5]”, which is nice for
more general contexts than just matrix operations. Also, “print
($m=pdl([1,1],[0,1])” yields
[
[1 1]
[0 1]
]
which is also nice: items are rendered in the most natural way. That choice
forces row-major ordering, which is the opposite of the convention the
mathematics community chose. (Can’t blame ‘em — even Ben Franklin screwed up
the sign convention for electric charge…) The wart is that, if you want to hit
a column vector with $m, you have to say “$m_vec = $m x ($vec->(*1))” to
explicitly make $vec a column vector — the 0 dim works along a row, not a
column.
I don’t see a clean way around the dichotomy between natural array rendering
and use (which is row-major) and matrix notation (which is column-major). A
transpose has to happen somewhere — either in the way arrays are rendered
(column-major specification, which makes matrices work great but screws up
other applications) or in the way that they are created (row-major
specification, which makes column vectors more cumbersome to use but makes
other applications more convenient).
Sorry if this rambles, I wrote this before dashing off to a meeting.
Best,
Craig
> On Jun 4, 2017, at 3:36 PM, Chris Marshall <[email protected]> wrote:
>
> But...
>
> If you look at the dimension ordering in slicing
> where dim(0) is the left-most index, then PDL is
> actually using the same memory ordering as with
> fortan: dim0 iterates first, then dim1 increases,
> then dim2....
>
> In fact sequence(3,4) is in memory in this
> order: (0,0), (1,0), (2,0), (0,1), (1,1), (2,1),
> (0,2), (1,2), (2,2), (0,3), (1,3), (2,3) which
> is exactly the memory order of a(3,4) in fortran.
>
> It seems the issue is that *displaying* the
> data uses C ordering. If we were to display
> the data as if transposed, then PDL would seem
> to me to be a column major storage system.
>
> I wonder what would happen if matrix operations
> used the natural dimension order rather than
> the imposed C ordering? It would get rid of
> all the nasty transposes in the matrix multiplication
> and things the tensor sums would compose naturally.
>
> Am I the only one who thinks PDL for matrix ops is
> a bit screwy---but for no good reason?
>
> --Chris
>
> On 6/4/2017 16:27, Grégory Vanuxem wrote:
>> Hi here,
>>
>> https://docs.oracle.com/cd/E19957-01/805-4940/z400091044d0/index.html
>> <https://docs.oracle.com/cd/E19957-01/805-4940/z400091044d0/index.html>
>>
>> Just for information.
>>
>> Now, an other thing to know.
>> Imagine I have a 2x2 matrix.
>>
>> If I write in the computer memory 4 integer’s (1-2-3-4) in one time, in C
>> this will be in matrix representation :
>>
>> 1 2
>> 3 4
>>
>> But in Fortran, like in mathematics :
>>
>> 1 3
>> 2 4
>>
>> So operations on these two representations are completely differents.
>>
>> Generaly computations on matrices are done on a very low level and use
>> directly the memory areas (no aware of indexing scheme).
>>
>> Hope that helps
>> __
>> Greg
>>
>> De : Luis Mochan <mailto:[email protected]>
>> Envoyé le :jeudi 1 juin 2017 20:06
>> À : [email protected]
>> <mailto:[email protected]>
>> Objet :Re: [Pdl-general] SVD
>>
>> Still confusing:
>> On Wed, May 31, 2017 at 03:36:33PM +1000, Karl Glazebrook wrote:
>> > column-major all the way down, as image processing came before matrix ops
>> > and i in A(i,j) is naturally the x-axis.
>> but the x axis displays horizontally, as row, and when matrices are
>> multiplied i is interpreted as column index, i.e., as index along row.
>> > i.e. A[0,1] is followed by A[1,0] in memory
>> You mean A[0,0] is followed by A[1,0] in memory, right?
>> So memory is arranged as in fortran arrays (first index fastest), but
>> the interpretation as row and column indices is different.
>> Regards,
>> Luis
>>
>>
>>
>> >
>> >
>> > Karl
>> >
>> >
>> >
>> > > On 22 May 2017, at 6:32 am, Chris Marshall <[email protected]>
>> > > <mailto:[email protected]> wrote:
>> > >
>> > > Please ignore the following. Just mark me confused...
>> > >
>> > > --Chris
>> > >
>> > > On 5/21/2017 15:51, Chris Marshall wrote:
>> > >> The row-major and col-major for PDL has always
>> > >> confused me since, AFAICT the PDL dimensions and
>> > >> slicing syntax actually are column major in
>> > >> memory but we print them out in row-major.
>> > >>
>> > >> Maybe one of the original PDL developers could
>> > >> give an explanation (of the history at least!).
>> > >>
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > Check out the vibrant tech community on one of the world's most
>> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > > <http://sdm.link/slashdot>
>> > > _______________________________________________
>> > > pdl-general mailing list
>> > > [email protected]
>> > > <mailto:[email protected]>
>> > > https://lists.sourceforge.net/lists/listinfo/pdl-general
>> > > <https://lists.sourceforge.net/lists/listinfo/pdl-general>
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > <http://sdm.link/slashdot>
>> > _______________________________________________
>> > pdl-general mailing list
>> > [email protected]
>> > <mailto:[email protected]>
>> > https://lists.sourceforge.net/lists/listinfo/pdl-general
>> > <https://lists.sourceforge.net/lists/listinfo/pdl-general>
>> >
>>
>> --
>>
>> o
>> W. Luis Mochán, | tel:(52)(777)329-1734
>> <tel:(52)(777)329-1734> /<(*)
>> Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\
>> Apdo. Postal 48-3, 62251 | (*)/\/ \
>> Cuernavaca, Morelos, México | [email protected]
>> <mailto:[email protected]> /\_/\__/
>> GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> <http://sdm.link/slashdot>
>> _______________________________________________
>> pdl-general mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.sourceforge.net/lists/listinfo/pdl-general
>> <https://lists.sourceforge.net/lists/listinfo/pdl-general>
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>> Garanti sans virus. www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>> <x-msg://147/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> <http://sdm.link/slashdot>
>>
>> _______________________________________________
>> pdl-general mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.sourceforge.net/lists/listinfo/pdl-general
>> <https://lists.sourceforge.net/lists/listinfo/pdl-general>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org <http://slashdot.org/>!
> http://sdm.link/slashdot_______________________________________________
> <http://sdm.link/slashdot_______________________________________________>
> pdl-general mailing list
> [email protected] <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/pdl-general
> <https://lists.sourceforge.net/lists/listinfo/pdl-general>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general