Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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 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|]. If incx is zero, then all elements of the vector have the same value, x[0]. The size of the one-dimensional array that stores the vector must always be at least

idimx = 1 + (n-1)* |incx |

Example. One-dimensional Real Array

Let x[0:6] be the one-dimensional real array

x = [1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0].

If incx =2 and n = 3, then the vector argument with elements in order from first to last is [1.0, 5.0, 9.0].

If incx = -2 and n = 4, then the vector elements in order from first to last is [13.0, 9.0, 5.0, 1.0].

If incx = 0 and n = 4, then the vector elements in order from first to last is [1.0, 1.0, 1.0, 1.0].

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 m-by-n matrix can be based on either column-major ordering where the increment between elements in the same column is 1, the increment between elements in the same row is m, and the increment between elements on the same diagonal is m + 1; or row-major ordering where the increment between elements in the same row is 1, the increment between elements in the same column is n, and the increment between elements on the same diagonal is n + 1.

Example. Two-dimensional Real Matrix

Let 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)

NOTE:

The default vector argument is assumed to be 1.