Vector Arguments in BLAS
Vector
arguments are passed in one-dimensional arrays. The
array
dimension (length) and vector
increment are passed as integer variables. The length determines the number of elements in the vector. The increment (also called stride) determines the spacing between vector elements and the order of the elements in the array in which the vector is passed.
A vector of
length
n
and increment
incx
is passed in a one-dimensional array
x
whose values are defined as
x[0], x[|incx|], ..., x[(n-1)* |incx|]
If
. If
. The size of the one-dimensional array that stores the vector must always be at least
incx
is positive, then the elements in array
x
are stored in increasing order. If
incx
is negative, the elements in array
x
are stored in decreasing order with the first element defined as
x
[(n
-1)* |incx
|]incx
is zero, then all elements of the vector have the same value,
x
[0]idimx = 1 + (n-1)* |incx |
Example.
One-dimensional Real ArrayLet
be the one-dimensional real array
x
[0:6]x = [1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0].
If
and
, then the vector argument with elements in order from first to last is
1.0, 5.0, 9.0.
incx
=2n
= 3[
]
If
and
, then the vector elements in order from first to last is
13.0, 9.0, 5.0, 1.0.
incx
= -2n
= 4[
]
If
and
, then the vector elements in order from first to last is
1.0, 1.0, 1.0, 1.0.
incx
= 0n
= 4[
]
One-dimensional substructures of a matrix, such as the rows, columns, and diagonals, can be passed as
vector arguments with the starting address and increment specified.
Storage of the
matrix can be based on either
column-major ordering where the increment between elements in the same column is
; or row-major ordering where the increment between elements in the same row is
.
m
-by-n
1
, the increment between elements in the same row is
m
, and the increment between elements on the same diagonal is
m
+ 11
, the increment between elements in the same column is
n
, and the increment between elements on the same diagonal is
n
+ 1Example.
Two-dimensional Real MatrixLet
a
be a real 5 x 4 matrix declared as
.
To scale the third column of
a
by 2.0, use the BLAS routine
sscal
with the following calling sequence:
cblas_sscal (5, 2.0, a[2], 4)
To scale the second row, use the statement:
cblas_sscal (4, 2.0, a[4], 1)
To scale the main diagonal of
a
by 2.0, use the statement:
cblas_sscal (4, 2.0, a[0], 5)
The default vector argument is assumed to be 1.