zeigvalsh Function

function zeigvalsh(A) result(lam)

Arguments

Type IntentOptional Attributes Name
complex(kind=8), intent(in) :: A(:,:)

Return Value real(kind=8), (size(A,1))


Calls

proc~~zeigvalsh~2~~CallsGraph proc~zeigvalsh~2 zeigvalsh assert_shape assert_shape proc~zeigvalsh~2->assert_shape zheevd zheevd proc~zeigvalsh~2->zheevd

Source Code

function zeigvalsh(A) result(lam)
  complex(8),intent(in) :: A(:, :)         ! matrix for eigenvalue compuation
  real(8)               :: lam(size(A,1))  ! eigenvalues: A c = lam c
  real(8), allocatable  :: At(:,:),work(:),rwork(:),iwork(:)
  real(8)               :: lwork_guess(1),lrwork_guess(1),liwork_guess(1)
  integer               :: info, lda,lwork,lrwork,liwork,n
  lda   = size(A(:,1))
  n     = size(A(1,:))
  call assert_shape(A,[n,n],"solve","A")
  allocate(At(n,n))
  !Copy the input Matrix
  At    = A
  !1st Call: Query the right size for the working array.
  call zheevd('N','U', n, At, lda, lam, lwork_guess,-1, lrwork_guess,-1, liwork_guess,-1, info )
  if(info /= 0) then
     print*, "zsyevd returned info = ",info
     stop
  endif
  lwork  = int(lwork_guess(1))  ;allocate(work(lwork))
  rwork  = int(lrwork_guess(1)) ;allocate(rwork(lrwork))
  liwork = int(liwork_guess(1)) ;allocate(iwork(liwork))
  !2nd Call: Actual solution of the eigenproblem
  call zheevd('N','U', n, At, lda, lam, work,lwork, rwork,lrwork, iwork,liwork, info )
  if(info /= 0) then
     print *, "zheevd returned info = ",info
     if (info < 0) then
        print*, "the",-info,"-th argument had an illegal value"
     else
        print*,"the algorithm failed to converge"
        print*,"the",info,"off-diagonal elements of an intermediate"
        print*,"tridiagonal form did not converge to zero"
     end if
     stop 'zeigvalsh error: 2nd call zheevd'
  end if
end function zeigvalsh