
Matrix representation is a method used by a
computer language
A computer language is a formal language used to communicate with a computer. Types of computer languages include:
* Construction language – all forms of communication by which a human can specify an executable problem solution to a compu ...
to store
matrices
Matrix most commonly refers to:
* ''The Matrix'' (franchise), an American media franchise
** ''The Matrix'', a 1999 science-fiction action film
** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchis ...
of more than one dimension in
memory
Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembered, ...
.
Fortran and
C use different schemes for their native arrays.
Fortran uses "Column Major", in which all the elements for a given column are stored contiguously in memory.
C uses "Row Major", which stores all the elements for a given row contiguously in memory.
LAPACK
LAPACK ("Linear Algebra Package") is a standard software library for numerical linear algebra. It provides routines for solving systems of linear equations and linear least squares, eigenvalue problems, and singular value decomposition. It also ...
defines various matrix representations in memory. There is also
Sparse matrix representation
In numerical analysis and scientific computing, a sparse matrix or sparse array is a matrix (mathematics), matrix in which most of the elements are zero. There is no strict definition regarding the proportion of zero-value elements for a matrix ...
and
Morton-order matrix representation.
According to the documentation, in
LAPACK
LAPACK ("Linear Algebra Package") is a standard software library for numerical linear algebra. It provides routines for solving systems of linear equations and linear least squares, eigenvalue problems, and singular value decomposition. It also ...
the
unitary matrix
In linear algebra, a complex square matrix is unitary if its conjugate transpose is also its inverse, that is, if
U^* U = UU^* = UU^ = I,
where is the identity matrix.
In physics, especially in quantum mechanics, the conjugate transpose is ...
representation is optimized.
Some languages such as
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
store matrices using
Iliffe vector
In computer programming, an Iliffe vector, also known as a display, is a data structure used to implement multi-dimensional arrays. An Iliffe vector for an ''n''-dimensional array (where ''n'' ≥ 2) consists of a vector (or 1-dimension ...
s. These are particularly useful for storing
irregular matrices. Matrices are of primary importance in
linear algebra
Linear algebra is the branch of mathematics concerning linear equations such as:
:a_1x_1+\cdots +a_nx_n=b,
linear maps such as:
:(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n,
and their representations in vector spaces and through matrices.
...
.
Basic mathematical operations
An m × n (read as m by n) order
matrix
Matrix most commonly refers to:
* ''The Matrix'' (franchise), an American media franchise
** ''The Matrix'', a 1999 science-fiction action film
** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchis ...
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, the condition being that the number of columns of the first matrix is equal to the number of rows of the second matrix. Hence, if an m × n matrix is multiplied with an n × r matrix, then the resultant matrix will be of the order m × r.
Operations like row operations or column operations can be performed on a matrix, using which we can obtain the inverse of a matrix. The inverse may be obtained by determining the adjoint as well.
rows and columns are the different classes of matrices
Basics of 2D array
The mathematical definition of a matrix finds applications in computing and database management, a basic starting point being the concept of
arrays
An array is a systematic arrangement of similar objects, usually in rows and columns.
Things called an array include:
{{TOC right
Music
* In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
. A two-dimensional array can function exactly like a matrix.
Two-dimensional arrays can be visualized as a table consisting of rows and columns.
* , declares an integer array of 3 rows and 4 columns. Index of row will start from 0 and will go up to 2.
* Similarly, index of column will start from 0 and will go up to 3.
This table shows arrangement of elements with their indices.
Initializing Two-Dimensional arrays: Two-Dimensional arrays may be initialized by providing a list of initial values.
int a 3] = ; or
int a 3] = ;
Calculation of Address
An m×n matrix () where the row index varies from 1 to m and column index from 1 to n,a
ij denotes the number in the i
th row and the j
th column. In the computer memory, all elements are stored linearly using contiguous addresses. Therefore, in order to store a two-dimensional matrix a, two dimensional address space must be mapped to one-dimensional address space. In the computer's memory matrices are stored in either
row- and column-major order, row-major or column-major order form.
In 3D graphics
The choice of representation for 4×4 matrices commonly used in
3D graphics
3D computer graphics, or “3D graphics,” sometimes called CGI, 3D-CGI or three-dimensional computer graphics are graphics that use a three-dimensional representation of geometric data (often Cartesian) that is stored in the computer for the ...
affects the implementation of matrix/vector operations in systems with packed
SIMD instruction
In computer science, an instruction set architecture (ISA), also called computer architecture, is an abstract model of a computer. A device that executes instructions described by that ISA, such as a central processing unit (CPU), is called an ' ...
s:
Row major
With row-major matrix order, it is easy to transform vectors using
dot product
In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a scalar as a result". It is also used sometimes for other symmetric bilinear forms, for example in a pseudo-Euclidean space. is an algebra ...
operations, since the coefficients of each component are sequential in memory. Consequently, this layout may be desirable if a processor supports dot product operations natively. It is also possible to efficiently use a '3×4' affine transformation matrix without padding or awkward permutes.
Column major
With column-major order, a "matrix × vector" multiply can be implemented with vectorized
multiply-add operations, if the vector's components are broadcast to each
SIMD lane Single instruction, multiple threads (SIMT) is an execution model used in parallel computing where single instruction, multiple data (SIMD) is combined with multithreading. It is different from SPMD in that all instructions in all "threads" are exe ...
. It is also easy to access the
basis vectors represented by a
transformation matrix as individual column vectors, as these are contiguous in memory.
See also
*
Row- and column-major order
*
Sparse matrix
*
Skyline matrix In scientific computing, skyline matrix storage, or SKS, or a variable band matrix storage, or envelope storage scheme is a form of a sparse matrix storage format matrix that reduces the storage requirement of a matrix more than banded storage. In ...
*
Locality of reference
References
{{Reflist
External links
a description of sparse matricesin R.
Matrices
Arrays