I'm new to lapack and trying to find the determinant of an NxN matrix. I used the code from dualm.wordpress.com/2012/01/06/computing-determinant-in-fortran/
program lapackdet
implicit none
integer :: N
complex, allocatable, dimension(:,:) :: mat
complex :: det
integer :: i, info
integer, allocatable :: ipiv(:)
real :: sgn
N=2
allocate(ipiv(N))
allocate(mat(N,N))
mat=2
mat(1,2)=1
mat(2,1)=1
ipiv=0
call zgetrf(N, N, mat, N, ipiv, info)
do i=1, N
det = det*mat(i,i)
end do
do i=1, N
if(ipiv(i)/=i)then
sgn=-sgn
end if
end do
det=sgn*det
write(*,*) det
end program lapackdet
When using this code, the error: "zgetrf", referenced from: det in cc8VZrbU.o ld: symbol(s) not found collect2: ld returned 1 exit status
I'm not sure what this means or how to fix it.
Thank you
zgetrfthat you call from your source code. Are you including the Lapack library on your link command? - M. S. B.detis not initialized to 1. - Kyle Kanos