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

Permutation vector for dgetrf

Jason_Jones1
Beginner
525 Views

I am having trouble with the output ipiv from dgetrf. My understanding is that it should return an array the length of the number of rows of my input matrix. Each member of this array should contain a different number. These numbers are the column in which a 1 would be placed for the corresponding column i.e. if:

ipiv =

1

4

5

2

3

This would correspond to a permutation matrix that looks like:

1 0 0 0 0

0 0 0 1 0

0 0 0 0 1

0 1 0 0 0

0 0 1 0 0

And that this permutation matrix P*X(my input matrix) = L*U. However, the ipiv outputs I get from dgetrf have many repetititions such as the output below and P*X != L*U:

ipiv = 4
ipiv = 2
ipiv = 4
ipiv = 4
ipiv = 5

Here is my example program:

#define M 5
#define N 5
int main()
{

int i,m, n, *ipiv, info;
double a[M*N] = { 3, 4, 6, 8, 2, 2, 9, 6, 1, 8, 12, 8, 4, 6, 2, 6, 6, 7, 1, 2, 9, 4, 3, 2, 8 };
ipiv = malloc(M*sizeof(int));
m = M;
n = N;
info = 0;

dgetrf(&m,&n,a,&m,ipiv,&info);
printf("info = %d\\n",info);

for (i=0;i{
printf("ipiv = %d\\n",ipiv);
}
return(0);
}

Thanks!

0 Kudos
2 Replies
TimP
Honored Contributor III
525 Views
If you wish to understand how this works, you will need to refer to the public netlib source code. I haven't looked for a while, but I believe your output indicates that the pivoting went like:
swap rows 1 and 4
continue processing
swap rows 3 and 4 (which was originally row 1)
continue...
The swap vector is intended to be used only by the companion BLAS functions.
0 Kudos
Jason_Jones1
Beginner
525 Views
Yes, that works. Thank you!
0 Kudos
Reply