I am using LAPACK to solve a linear sytem of equations A(n,n) * X(n,1) = B(n,1). A, X and B are real*8 (double precision).
First of all, I create A and B, initialize X to 0, and I then make a copy of A and B to A0 and B0, because A and B will be overwritten.
First of all, I use dgetrf to calculate LU factorization:
call dgetrf ( n, n, A, n, iPiv, info )
with integer*4 array iPiv(n). Matrix A gets overwritten by L and U, with unit diagonal elements not stored. This is clear.
I then continue with dgetrs to solve my system:
call dgetrs ( 'N', n, 1, A, n, iPiv, B, n, info )
where B contains the solution matrix X. Is the solution matrix a solution to the original system A * X = B or does it need to be reordered using iPiv? Right now, I simply copy B to X, hoping that no reordering is needed.
Finally, I am refining the solution X using dgerfs:
call dgerfs ( 'N', n, 1, A0, n, A, n, iPiv, B0, n, X, n, ferr, berr, work, iWork, info )
with ferr(1), berr(1), work(n) and iWork(n). For the final step, my questions are:
- Is any reordering needed for any of the variables used in the call to dgerfs?
- Documentation states that iWork must be (n), but it does not say anything about work for double precision flavors. It says (3*n) for real flavors; is that OK or should it rather be just (n)?