Storing Multidimensional Matrices in Memory: Matrix Representation

Lecture



Matrix representation is a method used by a programming language to store matrices of more than one dimension in memory . Fortran and C use different schemes for their native arrays. Fortran uses "column-major", in which all elements of a given column are stored contiguously in memory. C uses "row-major", which stores all elements of a given row contiguously in memory. LAPACK defines various matrix representations in memory. There is also a sparse matrix representation and a Morton-order matrix representation . According to the documentation, the unitary matrix representation is optimized in LAPACK. In some languages, such as Java , matrices are stored using Iliffe vectors . They are especially useful for storing irregular matrices . Matrices are of fundamental importance in linear algebra .

Storing Multidimensional Matrices in Memory: Matrix Representation

Illustration of row-major and column-major order

Basic mathematical operations

A matrix of order m × n (read "m by n") is a set of numbers arranged in m rows and n columns. Matrices of the same order can be added by adding the corresponding elements. Two matrices can be multiplied, provided that the number of columns of the first matrix equals the number of rows of the second matrix. Therefore, if an m × n matrix is multiplied by an n × r matrix, the resulting matrix will have order m × r.

Operations such as row operations or column operations can be performed on a matrix, and using them we can obtain the inverse matrix. The inverse can be obtained by determining the determinant and the adjugate. rows and columns are different classes of matrices

In 3D graphics

The choice of representation for the 4×4 matrices commonly used in 3D graphics affects the implementation of matrix/vector operations on systems with packed SIMD instructions :

Row-major

With row-major order, vectors are easy to transform using dot product operations, since the coefficients of each component are sequential in memory. Therefore, such a layout can be desirable if the processor natively supports dot product operations. It is also possible to efficiently use a "3 × 4" affine transformation matrix without padding or awkward shuffles.

Column-major

With column-major order, "matrix × vector" multiplication can be implemented with vectorized multiply-add operations if the vector components are broadcast to each SIMD lane . It is also easy to access the basis vectors represented by a transformation matrix as separate column vectors, since they are contiguous in memory.

See also

  • Row-major and column-major order
  • Sparse matrix
  • Skyline matrix
  • Locality of reference
  • [[b6192]]
  • [[b4323]]
  • [[b8510]]
  • [[b8941]]
  • [[b11952]]

See also

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Programming Languages and Methods / Translation Theory"

Terms: Programming Languages and Methods / Translation Theory