Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Philip_B_
Beginner
164 Views

Indices zero based or one based?

Jump to solution

Are indices in the Intel MKL BLAS and LAPACK function zero-based or one-based. For example the function idamax I think returns a zero-based argument with MKL CBLAS. However, my experience with Netlib was that this returned a one based index. There are also other functions such as dsyevx that require index arguments and I don't know whether these should be one-based or zero-based.

0 Kudos
1 Solution
164 Views

Hi Philip,

BLAS level 1 based CBLAS is 0 based indexing and LAPACK and LAPACKE are 1 based indexing.

--Vipin

View solution in original post

4 Replies
mecej4
Black Belt
164 Views

The original portable versions of BLAS and Lapack were written in Fortran, and therefore used the traditional 1-based indices of the language. Later, vendor-enhanced versions were supplied in pre-built library form, the sources of some routines written perhaps in assembler or C, but not released to the public. As C gained popularity, CBLAS and C-Lapack were born, and provided 0-based indices as the default or an option.

As of now, in calls to a library routine that is described as suitable for calling from C,C++,C# and Fortran, it is generally safe to call using 1-base indices. If the library is meant only for use with C/C++/C#, 0-base should be used. A tell-tale sign that a routine can be called with 0-base or 1-base is the presence of an extra (compared to the original BLAS/Lapack version) subroutine argument to specify the type of indexing used. If a library routine does not contain any integer arrays as dummy arguments, it is safe to assume that either 0- or 1-based arrays can be used, because in this case all internally used indices serve only to enable computing the offset from the array base, which is the same whichever convention is used.

Note that the situation is more complicated and your choices more restricted when one or more routine arguments are arrays of rank higher than 1.

When integer arrays containing indices of real array elements are routine arguments (such as an array of pivot indices for matrix factorization, or the iA, jA parts of a CSR or CSC compact matrix) are passed as subroutine arguments, in addition to the 0/1 base question of the integer size (32-bit or 64-bit) becomes a factor.

165 Views

Hi Philip,

BLAS level 1 based CBLAS is 0 based indexing and LAPACK and LAPACKE are 1 based indexing.

--Vipin

View solution in original post

Jakub_K_2
Beginner
164 Views

cblas_izamax() seems to be returning 0-based indexes.
However, MKL online documentation seems to be claiming 1-based indexes:
https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/562204

 

Gennady_F_Intel
Moderator
164 Views

Yakub, could you give the link to this part of online documentation to check this?

Reply