Matrix representation
Encyclopedia
Matrix representation is a method used by a computer language to store matrices
Matrix (mathematics)
In mathematics, a matrix is a rectangular array of numbers, symbols, or expressions. The individual items in a matrix are called its elements or entries. An example of a matrix with six elements isMatrices of the same size can be added or subtracted element by element...

 of more than one dimension in memory
Computer storage
Computer data storage, often called storage or memory, refers to computer components and recording media that retain digital data. Data storage is one of the core functions and fundamental components of computers....

.
Fortran
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

 and C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 use different schemes. Fortran
Fortran
Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing...

 uses "Column Major", in which all the elements for a given column are stored contiguously in memory. C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 uses "Row Major", which stores all the elements for a given row contiguously in memory.
LAPACK
LAPACK
-External links:* : a modern replacement for PLAPACK and ScaLAPACK* on Netlib.org* * * : a modern replacement for LAPACK that is MultiGPU ready* on Sourceforge.net* * optimized LAPACK for Solaris OS on SPARC/x86/x64 and Linux* * *...

 defines various matrix representations in memory. There is also Sparse matrix representation  and Morton-order matrix representation.
According to the documentation, in LAPACK
LAPACK
-External links:* : a modern replacement for PLAPACK and ScaLAPACK* on Netlib.org* * * : a modern replacement for LAPACK that is MultiGPU ready* on Sourceforge.net* * optimized LAPACK for Solaris OS on SPARC/x86/x64 and Linux* * *...

 the unitary matrix representation is optimized. Some languages such as Java store matrices using Iliffe vector
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 consists of a vector of pointers to an -dimensional array...

s. These are particularly useful for storing irregular matrices
Irregular matrix
An irregular matrix, or ragged matrix, can be described as a matrix that has a different number of elements in each row. Ragged matrices are not used in linear algebra, since standard matrix transformations cannot be performed on them, but they are useful as arrays in computing...

. Matrices are of primary importance in linear algebra
Linear algebra
Linear algebra is a branch of mathematics that studies vector spaces, also called linear spaces, along with linear functions that input one vector and output another. Such functions are called linear maps and can be represented by matrices if a basis is given. Thus matrix theory is often...

.

Basic mathematical operations

An m × n (read as m by n) order matrix
Matrix (mathematics)
In mathematics, a matrix is a rectangular array of numbers, symbols, or expressions. The individual items in a matrix are called its elements or entries. An example of a matrix with six elements isMatrices of the same size can be added or subtracted element by element...

 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.

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 array
Array
In computer science, an array data structure or simply array is a data structure consisting of a collection of elements , each identified by at least one index...

s. A two-dimensional array can function exactly like a matrix.
Two-dimensional arrays can be visualized as a table consisting of rows and columns.
  • int a[3][4], 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.































Column 0 Column 1 Column 2 Column 3
row 0 a[0][0] a[0][1] a[0][2] [0][3]
row 1 a[1][0] a[1][1] a[1][2] [1][3]
row 2 a[2][0] a[2][1] a[2][2] [2][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[2][3] = {1,2,3,4,5,6,} or int a[2][3] = ;

Calculation of Address :
An m x n matrix (a[1...m][1...n]) where the row index varies from 1 to m and column index from 1 to n,aij denotes the number in the ith row and the jth 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-major order
Row-major order
In computing, row-major order and column-major order describe methods for storing multidimensional arrays in linear memory. Following standard matrix notation, rows are numbered by the first index of a two-dimensional array and columns by the second index. Array layout is critical for correctly...

 or Column-major order form.

See also

  • Row- and column-major order
    Row-major order
    In computing, row-major order and column-major order describe methods for storing multidimensional arrays in linear memory. Following standard matrix notation, rows are numbered by the first index of a two-dimensional array and columns by the second index. Array layout is critical for correctly...

  • Sparse matrix
    Sparse matrix
    In the subfield of numerical analysis, a sparse matrix is a matrix populated primarily with zeros . The term itself was coined by Harry M. Markowitz....

  • Skyline matrix
    Skyline matrix
    A skyline matrix, or a variable band matrix, 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 banded storage, all entries within a fixed distance from the diagonal are stored...


External links


R. LEHOUCQ, The computation of elementary unitary matrices, Computer Science Dept. Technical Report CS-94-233, University of Tennessee, Knoxville, 1994. (LAPACK Working Note 72).
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK