Fix. template return type and potential error

isnan returns same layout as input (i.e., column vector in -> column
vector out).
median_ handles all data is NaN.