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

call dgesvx problem

Allison_G_
Beginner
356 Views

Hello,

I am trying to call the dgesvx routine in C++ using MKL 10.0.3.021 (windows, visual studio 2005 usingIntel C++ compiler). The routine returns -1 through the info argument indicating the first parameter has an illegal value. I have checked the first andall parameters and can't find the problem. The routine generates an access violation - I assume due to incorrectly specified argument(s) thatareexceedingbounds,but, again, I can'tdetermine which argument is the problem. I know the n, nrhs, a, lda, ipiv, b, ldb, and info arguments are OK since I use them correctly in a dgesv call. I have attacted the related code segment; the matrix 'system' is passed into this routine and I use it to initialize the matrix a which is input to dgesvx.

Thanks for your help.

const int AMPA_M = 19;
const int AMPA_N = 19;
mkl_set_num_threads(1);
// the matrix will be equilibrated if necessary, then copied to af and factored.
char fact[1];
fact[0] = 'E';
char trans[1];
trans[0] = 'N';
char equed[1];
equed[0] = 'R';

// n is the number of linear equations
int n = AMPA_M;
int nrhs = 1;
double a[AMPA_M][AMPA_N];
double af[AMPA_M][AMPA_N];
// row i of matrix a needs to be column i of original system that is
// input to this function
for (int column = 0; column < n; column++){
for (int row = 0; row < n; row++){
a[row][column] = system[column + 1][row + 1];
}
}
for (int row = 0; row < n; row++){
for (int column = 0; column < n; column++){
af[row][column] = 0;
}
}
int lda = n;
int ldaf = n;
int ldb = n;
int ldx = n;
int iwork = 4 * AMPA_N;
//double rwork = 2*n;
double b[AMPA_M];
for (int i = 0; i < AMPA_N; i++){
b = system[i + 1][AMPA_N + 1];
}
const int work_dim = 4 * AMPA_M;
double work[work_dim];
for (int i = 0; i < work_dim; i++){
work = 0;
}
int ipiv[AMPA_M];
double r[AMPA_M];
double c[AMPA_M];
double x[AMPA_M];
double ferr[AMPA_M];
double berr[AMPA_M];
for (int i = 0; i < AMPA_M; i++){
ipiv = 0;
r = 0;
c = 0;
x = 0;
ferr = 0;
berr = 0;
}
double rcond = 0;
int info = -25;
dgesvx(fact, trans, &n, &nrhs, (*a), &lda, (*af), &ldaf, ipiv, equed, r, c, b, &ldb, x, &ldx, &rcond, ferr, berr, work, &iwork, &info);
//dgesv(&n, &nrhs, (*a), &lda, ipiv, b, &ldb, &info);

for (int i = n - 1; i >= 0; i--){
x_return = b;
}

return info;

0 Kudos
4 Replies
Gennady_F_Intel
Moderator
356 Views

At the first glance all your parameters looks Ok,

So slightly changed your code

a[row][column] = (double)(column + 1)*(row + 1); //;system[column + 1][row + 1];

b = (double)(i+1)*(AMPA_N + 1);//system[i + 1][AMPA_N + 1];

and compiled under VS2005 with the addittianal dependencies:

mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libguide40.lib

and as a result I ve got:

info == 2

--Gennady

0 Kudos
Allison_G_
Beginner
356 Views

Hello, thanks for your reply.

I made the code changes you didwithout making any additional dependency changes and I got the same info == 2. But this doesn't solve my problem. This means that U is exactlysingular so apparently (I'm not sure but makes logical sense) the routine didn't go on processing as it would have with a "real" matrix that is nonsingular. With a nonsingular matrix the routine will go on and solve for x and compute error bounds. Somewhere in this processing it is generating the -1 based on my arguments.

Allison

0 Kudos
Gennady_F_Intel
Moderator
356 Views
Quoting - asgehrke

Hello, thanks for your reply.

I made the code changes you didwithout making any additional dependency changes and I got the same info == 2. But this doesn't solve my problem. This means that U is exactlysingular so apparently (I'm not sure but makes logical sense) the routine didn't go on processing as it would have with a "real" matrix that is nonsingular. With a nonsingular matrix the routine will go on and solve for x and compute error bounds. Somewhere in this processing it is generating the -1 based on my arguments.

Allison

0 Kudos
Gennady_F_Intel
Moderator
356 Views

Dear Allison,

at this case I would recommend you submit the issue against MKL to Premier support( https://premier.intel.com/ ). Gennady

0 Kudos
Reply