Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Treph
Beginner
112 Views

cgelss parameter error

Hi,

I am using cgelss() in a C++ program I am working on. Ever so often, the function prints out this error: "Intel MKL ERROR: Parameter 6 was incorrect on entry to CGELSS." Can someone explain to me what conditions would cause CGELSS to throw this error?

Thank you,

Treph

0 Kudos
6 Replies
mecej4
Black Belt
112 Views

Are you calling the Fortran routine directly, or are you calling its LapackE wrapper? Given the major differences in how C, C++ and Fortran treat multi-dimensional arrays, there are many ways of making mistakes with these calls. Rather than asking for different ways of making the call incorrectly, you will probably find it more useful to show the call in the form that it is made in your program (along with the declarations of the argument variables).

Gennady_F_Intel
Moderator
112 Views

Treph, please have a look at the existing example gelss.f90. You may find out it into mklroot/examples/lapack95/source directory.

Treph
Beginner
112 Views

mecej4 wrote:

Are you calling the Fortran routine directly, or are you calling its LapackE wrapper? Given the major differences in how C, C++ and Fortran treat multi-dimensional arrays, there are many ways of making mistakes with these calls. Rather than asking for different ways of making the call incorrectly, you will probably find it more useful to show the call in the form that it is made in your program (along with the declarations of the argument variables).

I am not using the LAPACKE_cgelss() call defined in mkl_lapacke.h.  I am using the cgelss() function call defined in mkl_lapack.h. Here is how I declare my argument varialbles: 

 

int m; // some size
int n;  // some size

MKL_Complex8* A = new MKL_Complex8[m*n];
MKL_Complex8* B = new MKL_Complex8;
float * S = new float ;

int lwork = {Generated by an empty cgelss call};
MKL_Complex8* Work = new MKL_Complex8[lwork];
float * rwork = new float[lwork];

int nrhs = 1;
float rcond = -1;
int rank = 0;
int info  = 0;

cgelss(&m, &n, &nrhs, A, &m, B, &m, S, &rcond, &rank, Work, &lwork, rwork, &info); 

 

Does anything stick out to you as wrong? Also, most of the time this call works. It is a just a few times the call throws the parameter 6 error.

-Treph

mecej4
Black Belt
112 Views

It is not easy to diagnose the problem on the basis on just snippets of code, but here is a question that occurred to me: 

You probably have at least some cases with m < n since you are calling CGELSS. In this case, in the mathematical sense, with A X = B, B is (m x nrhs) in size, and X is (n x nrhs).  With the CGELSS call however, the solution X is supposed to overwritten to B, so the array should be of size (max(m,n) x nrhs). Does your usage satisfy this requirement?

Treph
Beginner
112 Views

At first glance, it seems my usage should satisfy this case. However, how would MKL flag this condition since I am only passing in a pointer for B? Doesn't MKL just assume B's buffer size satisfies size(max(m,n) x nrhs)?

mecej4
Black Belt
112 Views

The routine probably checks if ldB >= max(m,n). In your call, you give the value of ldB as m, which would be incorrect when m < n. You could confirm by looking at the source code on Netlib (http://www.netlib.org/lapack/explore-html/de/d63/cgelss_8f_source.html), but MKL may use a modified version of that source code.

Reply