HP MLIB User's Guide Vol. 1 7th Ed.

Chapter 3 Basic Matrix Operations 213
Matrix-vector multiply SGBMV/DGBMV/CGBMV/ZGBMV
The following example illustrates the storage of general band matrices.
Consider the following matrix A of size m = 9 by n = 8, with lower and upper
bandwidths kl = 2 and ku = 3, respectively:
A is given in an array ab with at least kl+ku+1 = 6rows and n = 8 columns as
follows:
The asterisks in the ku-by-ku triangle at the upper left corner and in the
(kl+nm)-by-(kl+nm) triangle at the lower right corner represent elements of
ab that are not referenced. Thus, if a
ij
is an element within the band of A, then
it is stored in ab(ku+1+ij,j). Therefore, the columns of A are stored in the
columns of ab, and the diagonals of A are stored in the rows of ab, such that the
principal diagonal is stored in row ku+1 of ab.
Usage VECLIB:
CHARACTER*1 trans
INTEGER*4 m, n, kl, ku, ldab, incx, incy
REAL*4 alpha, beta, ab(ldab, n), x(lenx), y(leny)
CALL SGBMV(trans, m, n, kl, ku, alpha, ab, ldab, x, incx, beta, y, incy)
CHARACTER*1 trans
INTEGER*4 m, n, kl, ku, ldab, incx, incy
REAL*8 alpha, beta, ab(ldab, n), x(lenx), y(leny)
CALL DGBMV(trans, m, n, kl, ku, alpha, ab, ldab, x, incx, beta, y, incy)
111213140000
21 22 23 24 25 0 0 0
31 32 33 34 35 36 0 0
0424344454647 0
0 0 53 54 55 56 57 58
0 0 0 64 65 66 67 68
000075767778
00000868788
0000009798
* * * 14 25 36 47 58
* * 13 24 35 46 57 68
*12233445566778
11 22 33 44 55 66 77 88
21 32 43 54 65 76 87 98
31 42 53 64 75 86 97 *