utility_inv3 Subroutine

public subroutine utility_inv3(a, b, det)

Return in b the adjoint of the 3x3 matrix a, and its determinant. The inverse is defined as the adjoind divided by the determinant, so that inverse(a) = b/det

Arguments

Type IntentOptional AttributesName
real(kind=dp), intent(in) :: a(3,3)
real(kind=dp), intent(out) :: b(3,3)
real(kind=dp), intent(out) :: det

Called by

proc~~utility_inv3~~CalledByGraph proc~utility_inv3 utility_inv3 proc~boltzwann_main boltzwann_main proc~boltzwann_main->proc~utility_inv3 proc~wann_phases wann_phases proc~wann_phases->proc~utility_inv3 proc~wann_main wann_main proc~wann_main->proc~wann_phases proc~wann_main_gamma wann_main_gamma proc~wann_main_gamma->proc~wann_phases program~wannier wannier program~wannier->proc~wann_main program~wannier->proc~wann_main_gamma proc~wannier_run wannier_run proc~wannier_run->proc~wann_main proc~wannier_run->proc~wann_main_gamma

Contents

Source Code


Source Code

  subroutine utility_inv3(a, b, det)                   !
    !==================================================================!
    !                                                                  !
    !! Return in b the adjoint of the 3x3 matrix a, and its
    !! determinant.
    !! The inverse is defined as the adjoind divided by the
    !! determinant, so that inverse(a) = b/det
    !                                                                  !
    !===================================================================

    implicit none
    real(kind=dp), intent(in)  :: a(3, 3)
    real(kind=dp), intent(out) :: b(3, 3)
    real(kind=dp), intent(out) :: det

    real(kind=dp):: work(6, 6)
    integer :: i, j, k, l, ll, kk

    do i = 1, 2
      do j = 1, 2
        do k = 1, 3
          do l = 1, 3
            kk = 3*(i - 1) + k
            ll = 3*(j - 1) + l
            work(kk, ll) = a(k, l)
          end do
        end do
      end do
    end do

    det = 0.0_dp
    do i = 1, 3
      det = det + work(1, i)*work(2, i + 1)*work(3, i + 2)
    end do

    do i = 4, 6
      det = det - work(1, i)*work(2, i - 1)*work(3, i - 2)
    end do

    do j = 1, 3
      do i = 1, 3
        b(j, i) = (work(i + 1, j + 1)*work(i + 2, j + 2) - work(i + 1, j + 2) &
                   *work(i + 2, j + 1))
      end do
    end do

    return

  end subroutine utility_inv3