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

dpotri problem when calling from C

danesh_d
Beginner
780 Views

Hi,

I want to calculate inversion of a symmetric matrix using Cholesky factorization in C using "dpotri" MKL's LAPACK function. I wrote this code:

int info=0;
int param1=n*n;
int param2=n;
char* uplo="U";
dpotri(uplo, &param1, M, &param2, &info);

where "M" is a "nxn" symmetric matrix. The is compiled successfully but when I run the pogram, it says that parameter 4 (LDA which is defined "n" here) is incorrect. Should't it be "n" for a "nxn" matrix? Also, should I call "dpotrf" before "dpotri"?

Thanks for your help,

D.

0 Kudos
3 Replies
TimP
Honored Contributor III
780 Views
Quoting - danesh_d

int info=0;
int param1=n*n;
int param2=n;
char* uplo="U";
dpotri(uplo, &param1, M, &param2, &info);

where "M" is a "nxn" symmetric matrix. The is compiled successfully but when I run the pogram, it says that parameter 4 (LDA which is defined "n" here) is incorrect. Should't it be "n" for a "nxn" matrix? Also, should I call "dpotrf" before "dpotri

Should it be param1=n ? The matrix has to be dimensionedby the square of that value, which may not exceed param2.

It does require execution of potrf first.

http://www.intel.com/software/products/mkl/docs/WebHelp/lle/functn_potri.html

0 Kudos
danesh_d
Beginner
780 Views
Quoting - tim18

Should it be param1=n ? The matrix has to be dimensionedby the square of that value, which may not exceed param2.

It does require execution of potrf first.

http://www.intel.com/software/products/mkl/docs/WebHelp/lle/functn_potri.html

I think param1 is set correctly which is "n^2" for an "nxn" matrix which is order of that matrix. param2 is the problem which is "LDA" and should be "LDA>=max(1, param1)". Am I right? I don't know what "LDA" is. It is defined as "first dimension of matrix". I set param1=n and param2=n*n and got "segmentation fault" error. Same error for param1=param2=n*n.

D.

0 Kudos
Michael_C_Intel4
Employee
780 Views

Hello,

param1 should definitely be set to the linear size of the matrix.

LDA is "a leading dimension of A", it could be referred to as a stride. If 2-d array is continuous in memory, the stride is equal to the first dimension of the matrix (in case of 2-d array in C language it would be the last dimension).

In your particular case param1=param2=n should be set.

Michael.

0 Kudos
Reply