function get_helement_rs_hub_general(nI, nJ, ic_ret) result(hel)
integer, intent(in) :: nI(nel), nJ(nel)
integer, intent(inout), optional :: ic_ret
HElement_t(dp) :: hel
integer :: ic, ex(2, maxExcit)
logical :: tpar
integer(n_int) :: ilutI(0:NIfTot), ilutJ(0:NIfTot)
if (present(ic_ret)) then
if (ic_ret == 0) then
hel = get_diag_helemen_rs_hub(nI)
else if (ic_ret == 1) then
ex(1, 1) = 1
! exchange for fix with twisted BCs
call GetExcitation(nI, nJ, nel, ex, tpar)
hel = get_offdiag_helement_rs_hub(nI, ex(:, 1), tpar)
else if (ic_ret == 2 .and. t_trans_corr_hop) then
ex(1, 1) = 2
call GetExcitation(nI, nJ, nel, ex, tpar)
hel = get_double_helem_rs_hub_transcorr(ex, tpar)
else if (ic_ret == -1) then
! this indicates that ic_ret wants to get returned instead of
! beeing calculated
! its the same as if no ic_ret is present
call EncodeBitDet(nI, ilutI)
call EncodeBitDet(nJ, ilutJ)
ic_ret = FindBitExcitLevel(ilutI, ilutJ)
if (ic_ret == 0) then
hel = get_diag_helemen_rs_hub(nI)
else if (ic_ret == 1) then
ex(1, 1) = 1
! exchange for fix with twisted BCs
call GetBitExcitation(ilutI, ilutJ, ex, tpar)
hel = get_offdiag_helement_rs_hub(nI, ex(:, 1), tpar)
else if (ic_ret == 2 .and. t_trans_corr_hop) then
ex(1, 1) = 2
call GetBitExcitation(ilutI, ilutJ, ex, tpar)
hel = get_double_helem_rs_hub_transcorr(ex, tpar)
else
hel = h_cast(0.0_dp)
end if
else
hel = h_cast(0.0_dp)
end if
else
call EncodeBitDet(nI, ilutI)
call EncodeBitDet(nJ, ilutJ)
ic = FindBitExcitLevel(ilutI, ilutJ)
if (ic == 0) then
hel = get_diag_helemen_rs_hub(nI)
else if (ic == 1) then
ex(1, 1) = 1
! exchange for fix with twisted BCs
call GetBitExcitation(ilutI, ilutJ, ex, tpar)
hel = get_offdiag_helement_rs_hub(nI, ex(:, 1), tpar)
else if (ic == 2 .and. t_trans_corr_hop) then
ex(1, 1) = 2
call GetBitExcitation(ilutI, ilutJ, ex, tpar)
hel = get_double_helem_rs_hub_transcorr(ex, tpar)
else
hel = h_cast(0.0_dp)
end if
end if
end function get_helement_rs_hub_general