I'm programming in fortran and trying to use the DGETRI matrix inverter from the Lapack package:
http://www.netlib.org/lapack/explore-html/df/da4/dgetri_8f.html
But very strangely it seems to be messing with all my variables. In this very simple example, my matrix A initialised at the beginning of the program changes as DGETRI is applied, even though DGETRI doesn't involve A…
Can anybody tell me what is going on? Thanks!
PROGRAM solvelinear
REAL(8), dimension(2,2) :: A,Ainv
REAL(8),allocatable :: work(:)
INTEGER :: info,lwork,i
INTEGER,dimension(2) :: ipiv
info=0
lwork=10000
allocate(work(lwork))
work=0
ipiv=0
A = reshape((/1,-1,3,3/),(/2,2/))
Ainv = reshape((/1,-1,3,3/),(/2,2/))
CALL DGETRI(2,Ainv,2,Ipiv,work,lwork,info)
print*,"A = "
do i=1,2
print*,A(i,:)
end do
END PROGRAM solve linear
This is the output:
A =
1.0000000000000000 0.0000000000000000
-1.0000000000000000 0.33333333333333331