add vectorized ifelse functions

This patch adds vectorized versions of ``ifelse``, as part of the efforts to address #4451.

Note: The ``ifelse`` method in Jeff's commit only applies to the cases where the condition is a scalar.