home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.graphics:14325 comp.windows.x.pex:709 comp.graphics.opengl:283
- Path: sparky!uunet!usna!dfr
- From: dfr@usna.navy.mil (PROF D. Rogers (EAS FAC))
- Newsgroups: comp.graphics,comp.windows.x.pex,comp.graphics.opengl
- Subject: Re: Row major or column major matrices?
- Message-ID: <2697@usna.NAVY.MIL>
- Date: 27 Jan 93 18:36:02 GMT
- References: <1993Jan22.124249.3817@eye.com> <1993Jan23.000930.26869@kpc.com> <1993Jan26.002210.18638@mapsut.einstein.com>
- Sender: news@usna.NAVY.MIL
- Followup-To: comp.graphics
- Organization: U. S. Naval Academy
- Lines: 34
-
- In article <1993Jan26.002210.18638@mapsut.einstein.com> jasper@iris.einstein.com (John Scott Peter XXXIII) writes:
- !Well, I eagerly await your agent of dismemberment....
- !
- !Actually, I have no clear preference, and I'll explain why. In all my
- !education (math and physics, B.S Physics UCLA 1986), only row-major matrices
- !were used, so I naturally think of that as the standard. However, I have an
- !idea as to why so many people are switching to column-major notation. It's
- !so that matrices can be post-multiplied instead of pre-multiplied! Post-
- !multiplication notation accords better with the compound operators of C and
- !C++. If you're writing a matrix class in C++, and you want to multiply one
- !matrix by another, it seems natural to define the operator `*=' as the
- !multiplication operator, such that:
- !
- ! A *= B means A = A * B.
- !
- !I was writing such a class for a simple 3-D graphics program, and I quickly
- !realised that the most common multiplication I wanted to do was PRE-
- !multiplication. I therefore said `Screw convention', and defined `*=' so
- !that
- !
- ! A *= B means A = B * A.
- !
- !So, my solution was to change the standard C relationship between `*=' and
- !`*'. Apparently, others decided it was better to change the very operation
- !of matrix multiplication to imply a column-major order, so that `A *= B'
- !would still mean `A = A*B'.
-
- To heck with C and C+ and Fortran etc. You'll should really look
- at how ANSI BASIC (yes that nasty word) handles matrices. How about
- like a mathematician would? Yup that's the way they do it AND
- it is all built into the language! Amazing. When are these modern
- langauage designers going to get with it.
-
- Dave Rogers
-