function apply_rotation_wf(ilut_list, rot_angle) result(rot_wf)
! function to apply a rotation of given angle to the whole wavefunction
! encoded in ilut_list
integer(n_int), intent(inout) :: ilut_list(:, :)
real(dp), intent(in) :: rot_angle
integer(n_int) :: rot_wf(size(ilut_list, 1), size(ilut_list, 2))
#ifdef DEBUG_
character(*), parameter :: this_routine = "apply_rotation_wf"
#endif
integer :: orig_orbs(nBasis / 2), trans_orbs(nBasis / 2), i, &
orig_states(nel, size(ilut_list, 2)), rot_states(nel, size(ilut_list, 2))
real(dp) :: orig_weights(size(ilut_list, 2)), temp_sign(lenof_sign), &
rot_weights(size(ilut_list, 2))
orig_orbs = get_spatial(brr(1:nBasis:2))
trans_orbs = apply_rotation(orig_orbs, rot_angle)
! decode the original information
do i = 1, size(ilut_list, 2)
call decode_bit_det(orig_states(:, i), ilut_list(:, i))
call extract_sign(ilut_list(:, i), temp_sign)
orig_weights(i) = temp_sign(1)
end do
call transform_states(orig_orbs, trans_orbs, size(ilut_list, 2), &
orig_states, orig_weights, ilut_list, rot_states, rot_weights, rot_wf)
end function apply_rotation_wf