function get_diagonal_matel(nI, ilut) result(diagH)
! Get the diagonal element for a determinant nI with ilut representation ilut
! In: nI - The determinant to evaluate
! ilut - Bit representation (only used with HPHF)
! Ret: diagH - The diagonal matrix element
integer, intent(in) :: nI(nel)
integer(n_int), intent(in) :: ilut(0:NIfTot)
#ifdef CMPLX_
debug_function_name("get_diagonal_matel")
#endif
real(dp) :: diagH
if (tHPHF) then
associate(h_el => hphf_diag_helement(nI, ilut))
#ifdef CMPLX_
ASSERT(near_zero(aimag(h_el)))
#endif
diagH = real(h_el, dp)
end associate
else
associate(h_el => get_helement(nI, nI, 0))
#ifdef CMPLX_
ASSERT(near_zero(aimag(h_el)))
#endif
diagH = real(h_el, dp)
end associate
end if
end function get_diagonal_matel