18
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Row-major orderとColumn-major order

Posted at

参考: Wikipedia: Row-major_order

行列を配列に格納するときにどのような順番に格納するかとしてRow-major orderとColumn-major orderの2種類があります。

たとえばこのような行列があったとき

Column-major orderとRow-major orderではそれぞれ以下のように配列に格納されます。

Address Column-major order Row-major order
0 a11 a11
1 a21 a12
2 a12 a13
3 a22 a21
4 a13 a22
5 a23 a23

Row-major order は C/C++/Objective-C (for C-style arrays), Mathematica, PL/I, Pascal, Speakeasy, SAS, and C#/CLI/.Net などで使われています。
Column-major order は Fortran, OpenGL and OpenGL ES, MATLAB, GNU Octave, S-Plus, R, Julia, Rasdaman, Scilab などで使われています。

並び順の異なる行列ライブラリ間でデータをやりとりする場合等は、気をつけましょう。

18
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?