Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 7/13/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 Indexing Methods

Classic VM mathematical functions work with unit stride. Strided VM mathematical functions (names with “I” suffix) work with arbitrary integer increments. Increments may be positive, negative or equal to zero. For example:

vsExpI (n, a, inca, r, incr)

is equivalent to:

for (i=0; i<n; i++)
{
    r[i * incr] = exp (a[i * inca]);
}

where

i – current index,

inca – input index increment,

incr – output index increment.

n – the number of elements to be computed (important: n is not the maximum array size).

So, when calling vsExpI(n, a, inca, r, incr) be sure that the input vector a is allocated at least for 1 + (n-1)*inca elements and the result vector r has a space for 1 + (n-1)*incr elements.

NOTE:
The order of computations is not guaranteed and no array bounds-checking is performed; therefore, the results for overlapped and in-place arrays are not generally deterministic for increments other than 1.

For output index increment, equal to 0, the result is not deterministic and generally nonsensical.

Use negative increments to step from base pointers in reverse order.

For example:

vsExpI (n, a, -2, r, -3)

is equivalent to:

for (i=0; i<n; i++)
{
    r[- i*3] = exp (a[-i*2]);
}
NOTE:
Pass pointers to the desired ending array element in memory as an argument for negative strides.

For example:

vsExpI (n, a, 2, r + 1000, -3).

Use a zero increment for one fixed argument rather than an array.

For example:

vsMulI (n, a, 1, b, 0, r, 1)

is equivalent to:

for (i=0; i<n; i++)
{
    r[i] = a[i] * b[0];
}

VM Pack/Unpack functions use the following indexing methods to do this task:

  • positive increment

  • index vector

  • mask vector

The indexing method used in a particular function is indicated by the indexing modifier (see the description of the <mod> field in Function Naming Conventions). For more information on the indexing methods, see Vector Arguments in VM.

Related information