!! File  : det.f90
!!
!! Creation Date: 06.11.2015; Time: 15:22
!! Time-stamp: <2015-11-08 18:33:31 (andrzejbaran)> 
!!
!! Andrzej Baran
!! IF UMCS, ul. Radziszewskiego 10, 20-031 Lublin, PL
!! baran@kft.umcs.lublin.pl
!!
function det(A,ipvt,n)
  implicit none
  integer, dimension(n) :: ipvt
  double precision, dimension(n,n) :: A
  double precision :: det
  integer :: i,n
  !
  ! calculate determinant of A
  ! call det following call to LAPACK ?getrf(...)
  !
  det = 1d0
  do i=1,n
     if (ipvt(i).ne.i) then
        det = -det * a(i,i)
     else
        det = det * a(i,i)
     endif
  end do
end function det
