Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Indices zero based or one based?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Philip_B_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-16-2015
03:58 AM

164 Views

Indices zero based or one based?

1 Solution

VipinKumar_E_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-16-2015
05:13 AM

164 Views

Hi Philip,

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

--Vipin

Link Copied

4 Replies

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-16-2015
05:12 AM

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.

VipinKumar_E_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-16-2015
05:13 AM

165 Views

Hi Philip,

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

--Vipin

Jakub_K_2

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-08-2016
07:05 AM

164 Views

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-08-2016
08:10 PM

164 Views

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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.