What you need to know to use vector subprograms

BLAS indexing conventions

This section describes handling stride arguments and forward and backward storage.

A vector in the BLAS is defined by three quantities:

Vector length

Array or starting element within an array

Increment, sometimes called stride—defines the number of storage units between successive vector elements

Forward storage

Suppose that X is a real array. Let N be the vector length and let INCX be the increment. Suppose that a vector x with components xi, i= 1, 2, ..., N, is stored

in X. If INCX ≥ 0, then xi is stored in

X(1 + (I1) INCX). This is forward storage starting from X(1) with stride equal to INCX, ending with X(1 + (N1) INCX). Thus, if N = 4 and INCX = 2, the vector components x1, x2, x3, and x4 are stored in the array

elements X(1), X(3), X(5), and X(7), respectively.

Backward storage

Some BLAS subprograms permit the backward storage of vectors, which is specified by using a negative INCX. If INCX < 0, then xi is stored in X(1 + (NI) INCX) or equivalently in X(1 (NI) INCX). This is backward storage starting from X(1 (N1) INCX) with stride equal to INCX, ending with X(1). Thus, if N = 4 and INCX = −2, the vector components x1, x2, x3, and x4 are stored in the array elements

X(7), X(5), X(3), and X(1), respectively.

INCX = 0 is only permitted by COPY routines in the legacy BLAS subprograms. When INCX = 0 is allowed, it means that x is a vector of length N, whose components all equal the value of X(1).

The notation (N,X,INCX) describes a BLAS vector. For example, if X is an array of dimension N, then (N,X,1) represents forward storage and (N,X,1) represents backward storage. If A is an M-by-Narray, then (M,A(1,J),1) represents column J and (N,A(I,1),M) represents row I. Finally, if an M-by-Nmatrix is embedded in the upper left-hand corner of an array B of size LDB by NMAX, then column J is (M,B(1,J),1) and row is I(N,B(I,1),LDB).

Chapter 2 Basic Vector Operations 35