### IPIV in LU decomposition in order to recover A

Posted:

**Thu Oct 13, 2016 10:59 am**Hello all:

I can see in the documentation of DGETRF that the function performs the factorization A=P*L*U (http://www.netlib.org/lapack/explore-ht ... 93e60.html).

I'm working with the matrix

which comes for an example of Matrix Computations, Golub and Van Loan, 4th edition. DGETRF outputs IPIV=[3 3 3], but if I apply this IPIV via DLASWP with K1=1, K2=3, and INCX=1 the correct factorization is P*A=L*U, and I need to apply DLASWP with INCX=-1 in order to obtain A=P*L*U.

So DLASWP with IPIV=[3 3 3], K1=1, K2=3, and INCX=1 makes the permutation matrix

so that P*A=L*U, but DLASWP with IPIV=[3 3 3], K1=1, K2=3, and INCX=-1 creates

so that A=P*L*U

Also, DGETRS applies as previous step DLASWP with INCX=1 in order to solve Ax=B, i.e. uses P*B, which corresponds to P*A=L*U. So, it is possible that the DGETRF documentation be wrong or have I misunderstood the function?

Thanks

I can see in the documentation of DGETRF that the function performs the factorization A=P*L*U (http://www.netlib.org/lapack/explore-ht ... 93e60.html).

I'm working with the matrix

- Code: Select all
`3 17 10`

2 4 -2

6 18 -12

which comes for an example of Matrix Computations, Golub and Van Loan, 4th edition. DGETRF outputs IPIV=[3 3 3], but if I apply this IPIV via DLASWP with K1=1, K2=3, and INCX=1 the correct factorization is P*A=L*U, and I need to apply DLASWP with INCX=-1 in order to obtain A=P*L*U.

So DLASWP with IPIV=[3 3 3], K1=1, K2=3, and INCX=1 makes the permutation matrix

- Code: Select all
`0 0 1`

1 0 0

0 1 0

so that P*A=L*U, but DLASWP with IPIV=[3 3 3], K1=1, K2=3, and INCX=-1 creates

- Code: Select all
`0 1 0`

0 0 1

1 0 0

so that A=P*L*U

Also, DGETRS applies as previous step DLASWP with INCX=1 in order to solve Ax=B, i.e. uses P*B, which corresponds to P*A=L*U. So, it is possible that the DGETRF documentation be wrong or have I misunderstood the function?

Thanks