[eigen] Submatrix of a matrix does not preserve majorness
• To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
• Subject: [eigen] Submatrix of a matrix does not preserve majorness
• From: Yuanchen Zhu <yuanchen.zhu@xxxxxxxxx>
• Date: Sat, 2 Feb 2019 10:47:58 +0800
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=UicpIn45O86QRW7yjlRoJGY9UH0OMJvNNmH+x4nF0aU=; b=vDzdTGOQTEf2WxC9VzhHKDtHLd2EjYRjBCb0vuitCS0PDcqn9t3S0pcQhbbboRe4+E wNccWFZ75pFQt3LRbVDSuXapz92GSkcxC4jk8cnGdSEHbI7VohXL5oeO3ec5olr4cBoM yHtKx920ZQgR8qJ04LhfA0gx3SXEsNEAoP1bEPFIjGb9ZG91YDZQVHeG3ZFyMLSbs0gp tWZ6Xnqp0IuSVslOE6VAVrD+9fCV0W2tEiTxhLdZSjpUGaiU+WFOHxBc9J0U+LbnxiXf RqlBot1VkawcVG9kvYjI/VZ8trySehif6tyvU2V7Of6n6tEFAtWLXxdgz4w/K/uyI20d m5UQ==

Hi,

I find it unintuitive that a submatrix of a matrix can change its majorness depending on if the submatrix is a row or a column. Say M is a column-majored matrix. Then M.row(i) is actually conceptually row-majored. This becomes an issue once you start to reshape the resulting 1D quantity, e.g, you might want treat pixels in a 2D image as a row of a big 3-row matrix. Then at the end, you want to unpack a row back into a 2d matrix. Natuarally, when you do unshape, you should preserve the majorness. But the row is actually row-majored, so if you don't change the majorness when you reshape, you get a row-majored matrix at the end.

To summarize: Having submatrix operations changing the majorness of the resulting submatrix depending on its shape is a library-wart. Can we change this behavior? Essentially once you choose a majorness convention for your application, all matrix operations should not change the majorness of the resulting matrix, unless EXPLICITLY requested by user, e.g., for efficiency.

Thanks,
Yuanchen

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/