Re: [eigen] Question about ColMajor vs. RowMajor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Question about ColMajor vs. RowMajor
- From: Douglas Bates <bates@xxxxxxxxxxxxx>
- Date: Fri, 16 Dec 2011 18:36:10 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=rS+Rl7SKyGiYxbHlzB2cfO8zIuQ05+9tjh9qmyYmqzw=; b=uTv4AF7wIynOaAa/THwzWMD+G+ivNeiQxnJCEp2JU5F6PsVuvry+9BCuKZq+ra4Iq1 IMnmBx/j5cDYIiKNSRgFuuCxOtFsaSenHMOppDw0LAeSeNJRwfcbvLtdtZvBrTfbW8Ye Rw2Jj5QPBaXohdVnNvWIX7wNT6X8Q/YUntlzI=
On Fri, Dec 16, 2011 at 6:27 PM, Michael Dixon <mdixon@xxxxxxxxxxxxxxxx> wrote:
> Hi,
> My colleagues and I were recently playing around with changing the
> default for matrices from ColMajor to RowMajor, and we found that
> doing so changed the behavior of the () operator. Specifically, when
> accessing a two-dimensional matrix with a single index (e.g., mat(i)
> ), the ColMajor/RowMajor flag affects which element of the matrix gets
> indexed as the ith. Our assumption had been that changing the
> ColMajor/RowMajor flag would be completely transparent, which is to
> say, it would affect the underlying storage (and thus the
> performance/efficiency), but it wouldn't change the overall behavior
> of the code. I was just wondering whether the altered behavior of the
> () operator was intended (in which case, our assumption of
> transparency was incorrect), or whether this was an unintended bug.
But the mapping from a one-dimensional array to a matrix is exactly
what ColMajor/RowMajor means. Using a single index into a ColMajor
matrix is the equivalent of using a single index into the transpose of
the same matrix in RowMajor ordering. For a 2 by 2 matrix the
ColMajor order is
0 2
1 3
whereas it is
0 1
2 3
for RowMajor