subroutine SetupUMat2d_dense(nBasis)
integer, intent(in) :: nBasis
integer :: nBI, i, j
integer :: ierr
character(*), parameter :: t_r = 'SetupUMat2d_dense'
nBI = numBasisIndices(nBasis)
! allocate the storage
if (.not. associated(UMat2D)) then
allocate(UMat2D(nBI, nBI), stat=ierr)
call LogMemAlloc('UMat2D', nBI**2, 8 * HElement_t_size, t_r, tagUMat2D, ierr)
end if
! and fill in the array
do i = 1, nBI
do j = 1, nBI
if (i == j) then
UMat2d(i, i) = get_umat_el(i, i, i, i)
else
! similarly the integrals <ij|ij> in UMat2D
UMat2D(j, i) = get_umat_el(i, j, i, j)
UMat2D(i, j) = get_umat_el(i, j, j, i)
end if
end do
end do
end subroutine SetupUMat2d_dense