subroutine gen_all_excits_k_space_hubbard(nI, n_excits, det_list)!, sign_list)
integer, intent(in) :: nI(nel)
integer, intent(out) :: n_excits
integer(n_int), intent(out), allocatable :: det_list(:, :)
integer(n_int), allocatable :: triple_dets(:, :), temp_dets(:, :)
integer :: n_triples, save_excits
call gen_all_doubles_k_space(nI, n_excits, det_list)!, sign_list)
if (t_trans_corr_2body) then
save_excits = n_excits
! also account for triple excitations
call gen_all_triples_k_space(nI, n_triples, triple_dets)
n_excits = n_excits + n_triples
allocate(temp_dets(0:niftot, save_excits), source=det_list(:, 1:save_excits))
deallocate(det_list)
allocate(det_list(0:niftot, n_excits))
det_list(:, 1:save_excits) = temp_dets
det_list(:, save_excits + 1:n_excits) = triple_dets
end if
call sort(det_list, ilut_lt, ilut_gt)
! if we have HPHF turned on we want to "spin-purify" the excitation
! list
if (tHPHF) then
save_excits = n_excits
if (allocated(temp_dets)) deallocate(temp_dets)
allocate(temp_dets(0:NIfTot, n_excits), source=det_list)
call spin_purify(save_excits, temp_dets, n_excits, det_list)
end if
end subroutine gen_all_excits_k_space_hubbard