comp_det Function

public function comp_det(array, n) result(det)

Uses

  • proc~~comp_det~~UsesGraph proc~comp_det comp_det module~precision precision proc~comp_det->module~precision iso_fortran_env iso_fortran_env module~precision->iso_fortran_env

This routine calculates the determinate of a square matrix. Gauss Elimination Method array the matrix of order norder which is to be evaluated. this subprogram destroys the matrix array norder the order of the square matrix to be evaluated.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout), dimension(n,n) :: array
integer, intent(in) :: n

Return Value real(kind=dp)


Called by

proc~~comp_det~~CalledByGraph proc~comp_det comp_det proc~ov_exact ov_exact proc~ov_exact->proc~comp_det proc~mrsf_tlf mrsf_tlf proc~mrsf_tlf->proc~ov_exact proc~compute_states_overlap compute_states_overlap proc~compute_states_overlap->proc~mrsf_tlf proc~get_states_overlap get_states_overlap proc~get_states_overlap->proc~compute_states_overlap proc~get_state_overlap_c get_state_overlap_C proc~get_state_overlap_c->proc~get_states_overlap

Source Code

  function comp_det(array, n) result(det)
    use precision, only: dp

    implicit none

    real(kind=dp) :: det
    real(kind=dp), intent(inout), dimension(n,n) :: array
    integer, intent(in) :: n

    real(kind=dp), dimension(n,n) :: work
    integer, dimension(n) :: num
    real(kind=dp) :: tmp, max
    integer i, k, l, m

    det = 1.0_dp
    do k = 1, n
       max = array(k,k)
       num(k) = k
       do i = k+1, n
          if(abs(max)<abs(array(i,k))) then
             max = array(i,k)
             num(k) = i
          end if
       end do
       if (num(k)/=k) then
          do l = k, n
             tmp = array(k,l)
             array(k,l) = array(num(k),l)
             array(num(k),l) = tmp
          end do
          det = -1.0_dp*det
       end if
       do m = k+1, n
          work(m,k) = array(m,k)/array(k,k)
          do l = k, n
             array(m,l) = array(m,l)-work(m,k)*array(k,l)
          end do
       end do !There we made matrix triangular!
    end do

    do i = 1, n
    det = det*array(i,i)
    end do

  end function comp_det