Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6977 Discussions

Const correctness of dgbtrs and friends in mkl_lapack.h?

Rhys_Ulerich
New Contributor I
368 Views
Any reason why the C interface to LAPACK's dgbtrf doesn't provide a const correct argument for ab and ipiv?
void dgbtrs( char* trans, MKL_INT* n, MKL_INT* kl, MKL_INT* ku, MKL_INT* nrhs, double* ab, MKL_INT* ldab, MKL_INT* ipiv, double* b, MKL_INT* ldb, MKL_INT* info );
It doesn't seem like the factored matrix or its pivots should be touched at all during the solve process.

0 Kudos
1 Solution
Vladimir_Koldakov__I
New Contributor III
368 Views

Hi Rhys,

Your question is not entirely clear to me. So I'll try to answer in general.

Arrays ab and ipiv are as returned by dgbtrf on the entry dbgtrs.

Arrays ab and ipiv are not changed within dgbtrs. The same is for n, kl, ku, nrhs, ldab and ldb arguments. All of them have not "const" specifier. You can't find "const" anywhere in the mkl_lapack.h. Of course this is not good enough and may be fixed in the further MKLreleases. In any case it has not impact on the functionality of the interfaces. See also CLAPACK thread: http://software.intel.com/en-us/forums/showthread.php?t=61234

Thanks,

Vladimir

View solution in original post

0 Kudos
5 Replies
Artem_V_Intel
Employee
368 Views
Quoting - Rhys Ulerich
Any reason why the C interface to LAPACK's dgbtrf doesn't provide a const correct argument for ab and ipiv?
void dgbtrs( char* trans, MKL_INT* n, MKL_INT* kl, MKL_INT* ku, MKL_INT* nrhs, double* ab, MKL_INT* ldab, MKL_INT* ipiv, double* b, MKL_INT* ldb, MKL_INT* info );
It doesn't seem like the factored matrix or its pivots should be touched at all during the solve process.

Hello,

It is guaranteed that the content of arguments that used only as input parameters will not be changed during function execution. 'const' modifier is redundant here.

Thanks,
Art
0 Kudos
Vladimir_Koldakov__I
New Contributor III
369 Views

Hi Rhys,

Your question is not entirely clear to me. So I'll try to answer in general.

Arrays ab and ipiv are as returned by dgbtrf on the entry dbgtrs.

Arrays ab and ipiv are not changed within dgbtrs. The same is for n, kl, ku, nrhs, ldab and ldb arguments. All of them have not "const" specifier. You can't find "const" anywhere in the mkl_lapack.h. Of course this is not good enough and may be fixed in the further MKLreleases. In any case it has not impact on the functionality of the interfaces. See also CLAPACK thread: http://software.intel.com/en-us/forums/showthread.php?t=61234

Thanks,

Vladimir

0 Kudos
Rhys_Ulerich
New Contributor I
368 Views
Arrays ab and ipiv are not changed within dgbtrs. The same is for n, kl, ku, nrhs, ldab and ldb arguments. All of them have not "const" specifier. You can't find "const" anywhere in the mkl_lapack.h. Of course this is not good enough and may be fixed in the further MKLreleases. In any case it has not impact on the functionality of the interfaces. See also CLAPACK thread: http://software.intel.com/en-us/forums/showthread.php?t=61234

Thanks Vladimir, that helps.
0 Kudos
Rhys_Ulerich
New Contributor I
368 Views
It is guaranteed that the content of arguments that used only as input parameters will not be changed during function execution. 'const' modifier is redundant here.


Thanks for the response Art. The guarentee that the input parameters won't be changed is exactly what const means. It's not redundant because including const in the interface would cause the compiler to enforce this semantic.
0 Kudos
mfactor
Beginner
368 Views
The need to pass via reference is a Fortran/C one, but I agree that they should be const.
0 Kudos
Reply