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
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 + (I−1) ⋅ INCX). This is forward storage starting from X(1) with stride equal to INCX, ending with X(1 + (N−1) ⋅ 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 + (N−I) ⋅ INCX) or equivalently in X(1 − (N−I) ⋅ INCX). This is backward storage starting from X(1 − (N−1) ⋅ 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
Chapter 2 Basic Vector Operations 35