Developer Reference for Intel® oneAPI Math Kernel Library for Fortran

ID 766686
Date 3/31/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(1), x(1+|incx|), ..., x(1+(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(1+(n-1)* |incx|). If incx is zero, then all elements of the vector have the same value, x(1). 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(1:7) 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.

In Fortran, storing the m-by-n matrix is based on 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.

Example. Two-dimensional Real Matrix

Let a be a real 5 x 4 matrix declared as REAL A (5,4)float a[5*4];.

To scale the third column of a by 2.0, use the BLAS routine sscal with the following calling sequence:

call sscal (5, 2.0, a(1,3), 1)

To scale the second row, use the statement:

call sscal (4, 2.0, a(2,1), 5)

To scale the main diagonal of a by 2.0, use the statement:

call sscal (5, 2.0, a(1,1), 6)

NOTE:

The default vector argument is assumed to be 1.