I am having trouble understanding C interface for MKL. In particular the const modifier. I need to use tridiagonal solver ?dtsvb which should have C interface:
void ddtsvb (const MKL_INT * n, const MKL_INT * nrhs, double * dl, double * d, const double * du, double * b, const MKL_INT * ldb, MKL_INT * info );
However, I have no idea what const MKL_INT * n stands for. Can someone provide a clear example of how the function ddtsvb is called?
?dtsvb solves a diagonally dominant triangular matrix with multiple right-hand-sides. The first argument to the function, const MKL_INT *n, is the order of matrix A, also the number of rows of matrix B. See the documentation: http://software.intel.com/en-us/node/468892
Thank you, but I know what it does, I use it in Fortran code, now I need to use it in C code. I just do not know what const modifier is supposed to mean:
ddtsvb (&n, &nrhs, dl, d, const du, b, const &ldb, &info );?
OR what is const supposed to do? In this regard the documentation is not clear.
Also I am not sure about arrays in MKL and C, C has zero based arrays, Fortran 1 based. How does MKL address that? Do I have to use arrays by one larger so that it can be used as 1 based ie. array[1+CSize] so that MKL can use array [1:CSize]?
The `const' modifier is a C language artifact. It is a guarantee made to the code that calls the C function, that the value of the argument is not changed when the function returns. In this particular example, arguments n, nrhs, du, and ldb are input-only arguments. The function does not overwrite them when it returns. In contrast, dl, b, and info are output arguments, so they are not `const'. When you call the function, you plug in only the names of the arguments, for example,
ddtsvb (&n, &nrhs, dl, d, du, b, &ldb, &info);
Arrays in the C interface always use 0-based indexing. This doesn't change the size of the array. It only affects indexing. For example, the first element of a Fortran array is located at position 1 (e.g. A(1) ), the first element of a C array is located at position 0 (e.g. A).