Packed storage matrix


A packed storage matrix, also known as packed matrix, is a term used in programming for representing an matrix. It is a more compact way than an m-by-n rectangular array by exploiting a special structure of the matrix.
Typical examples of matrices that can take advantage of packed storage include:

Triangular packed matrices

The packed storage matrix allows a matrix to be converted to an array, shrinking the matrix significantly. In doing so, a square matrix is converted to an array of length.
Consider the following upper matrix:
which can be packed into the one array:
Similarly the lower matrix:
can be packed into the following one dimensional array:

Code examples (Fortran)

Both of the following storage schemes are used extensively in BLAS and LAPACK.
An example of packed storage for Hermitian matrix:

complex :: A ! a hermitian matrix
complex :: AP ! packed storage for A
! the lower triangle of A is stored column-by-column in AP.
! unpacking the matrix AP to A
do j=1,n
k = j*/2
A = AP
A = conjg
end do

An example of packed storage for banded matrix:

real :: A ! a banded matrix with kl subdiagonals and ku superdiagonals
real :: AP ! packed storage for A
! the band of A is stored column-by-column in AP. Some elements of AP are unused.
! unpacking the matrix AP to A
do j = 1, n
forall:min) A = AP
end do
print *,AP ! the diagonal