Matrix representation
A matrix representation is a method used by a computer language to store matrices of more than one dimension in memory. Fortran and C use different schemes. 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 defines various matrix representations in memory. There is also Sparse matrix representation and Morton-order matrix representation. According to the documentation, in LAPACK the unitary matrix representation is optimized. See [1]. Some languages such as Java store matrices using Iliffe vectors. These are particularly useful for storing irregular matrices. This is a data structure related article.
Introduction
A m x n (read as m by n) matrix is a set of numbers arranged in m rows and n columns. You can add 2 matrices of the same size by adding individual elements. You can multiply 2 matrices as well. But the only condition is that the number of columns of the first matrix is equal to the number of rows of the second matrix. So if you multiply a m x n matrix with a n x r matrix then the resultant matrix will be of the order m x r. Similarly you can also find the inverse of a matrix by various methods like row-transformation , column transformation, ad-joint method, and many more. We can as well solve simultaneous linear equations by matrix method.
Theory
All this was related to mathematics. This same thing can be related to computing. A two-dimensional array can function exactly like a matrix. Two-dimensional arrays can be thought of as a table consisting of rows and columns.
- int a[3][4], declares an integer array of three rows and four columns. Row index will start from 0 and will go upto 2.
- Similarly, column index will start from 0 and will go upto 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] |
arrangement of elements and their indices.
Initializing Two-Dimensional arrays: Two-Dimensional arrays may be initialize by providing a list of initial values.
int a[2][3] = {1,2,3,4,5,6,} or int a[2][3] = {{2,3,4},{4,4,5}}; Address Calculation: 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 entry in the ith row and the jth column. In computer memory, all elements are stored linearly using contiguous addresses. Hence,in order to store a two-dimensional matrix a, two dimensional address space must be mapped to one dimensional (linear) address space.In the computer's memory matrices are stored in either Row-major order or Column-major order form.
See also
External links
- http://developer.r-project.org/Sparse.html a description of sparse matrices in R.
^1 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).