function apply_mirror_wf(ilut_list, mirror_axis, sort_ind) result(mir_wf)
! function to apply a mirror symmetry to the given wavefunction
! encoded in ilut_list
integer(n_int), intent(inout) :: ilut_list(:, :)
character(1), intent(in) :: mirror_axis
integer, intent(out), optional :: sort_ind(size(ilut_list, 2))
integer(n_int) :: mir_wf(size(ilut_list, 1), size(ilut_list, 2))
#ifdef DEBUG_
character(*), parameter :: this_routine = "apply_mirror_wf"
#endif
integer :: orig_orbs(nBasis / 2), trans_orbs(nBasis / 2), i, &
orig_states(nel, size(ilut_list, 2)), mir_states(nel, size(ilut_list, 2))
real(dp) :: orig_weights(size(ilut_list, 2)), temp_sign(lenof_sign), &
mir_weights(size(ilut_list, 2))
orig_orbs = get_spatial(brr(1:nBasis:2))
trans_orbs = apply_mirror(orig_orbs, mirror_axis)
! 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
if (present(sort_ind)) then
call transform_states(orig_orbs, trans_orbs, size(ilut_list, 2), &
orig_states, orig_weights, ilut_list, mir_states, mir_weights, &
mir_wf, sort_ind)
else
call transform_states(orig_orbs, trans_orbs, size(ilut_list, 2), &
orig_states, orig_weights, ilut_list, mir_states, mir_weights, mir_wf)
end if
end function apply_mirror_wf