Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

LAPACKE_dgetrs the input parameter

tctcyf
Beginner
800 Views

Qustion about the function:

dgetrs( trans, n, nrhs, a, lda, ipiv, b, ldb, info )

In the MKL Manual ,the ldb is the the first dimension of b,and ldb>=max(1,n),but when I used it in Vs2008I found

the ldb is the column of b

The example:

double A[9] = { 1, 1, 1,

2, 1, 1,

1, 2, 1};

double B[3] = { 3, 4, 6};

info1=LAPACKE_dgetrf(LAPACK_ROW_MAJOR,3,3,&(A[0]),3, &(ipiv[0]) );

info2 = LAPACKE_dgetrs(LAPACK_ROW_MAJOR,'N',3,1,&(A[0]),3,&(ipiv[0]),&(B[0]),1);

this is right,

but if I change the ldb to 3,
info2 = LAPACKE_dgetrs(LAPACK_ROW_MAJOR,'N',3,1,&(A[0]),3,&(ipiv[0]),&(B[0]),3);
it is wrong,

I wonder to know if the manual is wrong,or I don't understand the manual.
Thank's a lot

0 Kudos
2 Replies
mecej4
Black Belt
800 Views
This is a common source of confusion. Fortran and C store multidimensional arrays differently, and the manual attempts to cover the argument descriptions for the Fortran and C interfaces simultaneously.

Secondly, if you use one-dimensional arrays for matrices (which should be two-dimensional arrays), you need to understand the mapping correctly, or you will run into errors of the type that you saw.

The argument in question should be equal to the number of declared/allocated columns of B for the LapackE call, and the number of declared/allocated rows of B for the Fortran call.
0 Kudos
tctcyf
Beginner
800 Views
Thank you for your help!
0 Kudos
Reply