subroutine generate_connected_space_vector(trial_space, trial_vecs, con_space, con_vecs)
! Calculate the vector
! \sum_j H_{ij} \psi_j,
! where \psi is the trial vector, j runs over all trial space
! states and i runs over all connected space states. This is output
! in con_vecs.
use hphf_integrals, only: hphf_off_diag_helement
use MemoryManager, only: LogMemAlloc
integer(n_int), intent(in) :: trial_space(0:, :)
HElement_t(dp), intent(in) :: trial_vecs(:, :)
integer(n_int), intent(in) :: con_space(0:, :)
HElement_t(dp), intent(out) :: con_vecs(:, :)
integer :: i, j, ierr
integer :: nI(nel), nJ(nel)
HElement_t(dp) :: H_ij
character(len=*), parameter :: this_routine = "generate_connected_space_vector"
type(ExcitationInformation_t) :: excitInfo
type(CSF_Info_t) :: csf_i, csf_j
con_vecs = 0.0_dp
! do i need to change this here for the non-hermitian transcorrelated
! hamiltonians?
do i = 1, size(con_vecs, 2)
call decode_bit_det(nI, con_space(0:NIfTot, i))
! i am only here in the guga case if i use the new way to calc
! the off-diagonal elements..
if (tGUGA) csf_i = CSF_Info_t(con_space(0 : nifd, i))
do j = 1, size(trial_vecs, 2)
call decode_bit_det(nJ, trial_space(0:NIfTot, j))
if (tGUGA) csf_j = CSF_Info_t(trial_space(0:NIfTot, j))
if (all(con_space(0:nifd, i) == trial_space(0:nifd, j))) then
if (tHPHF) then
H_ij = hphf_diag_helement(nI, trial_space(:, j))
else if (tGUGA) then
H_ij = calcDiagMatEleGuga_nI(nI)
else
H_ij = get_helement(nI, nJ, 0)
end if
else
! need guga changes here!
! and need
if (tHPHF) then
! maybe i need a non-hermitian keyword here..
! since I am not sure if this breaks the kneci
H_ij = hphf_off_diag_helement(nJ, nI, trial_space(:, j), con_space(:, i))
! H_ij = hphf_off_diag_helement(nI, nJ, con_space(:,i), trial_space(:,j))
else if (tGUGA) then
ASSERT(.not. t_non_hermitian_2_body)
call calc_guga_matrix_element(&
con_space(:, i), csf_i, trial_space(:, j), csf_j, &
excitInfo, H_ij, .true.)
#ifdef CMPLX_
H_ij = conjg(H_ij)
#endif
! call calc_guga_matrix_element(con_space(:,i), trial_space(:,j), &
! excitInfo, H_ij, .true., 1)
else
! maybe i need a non-hermitian keyword here..
! since I am not sure if this breaks the kneci
H_ij = get_helement(nJ, nI, trial_space(:, j), con_space(:, i))
! H_ij = get_helement(nI, nJ, con_space(:,i), trial_space(:,j))
end if
end if
! workaround for complex matrix elements here:
#ifdef CMPLX_
H_ij = conjg(H_ij)
#endif
con_vecs(:, i) = con_vecs(:, i) + H_ij * trial_vecs(:, j)
end do
end do
end subroutine generate_connected_space_vector