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(n,n) ! a hermitian matrix complex:: AP(n*(n+1)/2) ! 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*(j-1)/2 A(1:j,j) = AP(1+k:j+k) A(j,1:j-1) = conjg(AP(1+k:j-1+k)) end doAn example of packed storage for banded matrix:
real:: A(m,n) ! a banded matrix with kl subdiagonals and ku superdiagonals real:: AP(-kl:ku,n) ! 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(i=max(1,j-kl):min(m,j+ku)) A(i,j) = AP(i-j,j) end do print *,AP(0,:) ! the diagonalRead more about this topic: Packed Storage Matrix
Famous quotes containing the words code and/or examples:
“Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.”
—Alice Foote MacDougall (18671945)
“It is hardly to be believed how spiritual reflections when mixed with a little physics can hold peoples attention and give them a livelier idea of God than do the often ill-applied examples of his wrath.”
—G.C. (Georg Christoph)