implement c code of nanmad
try to reduce code duplication by putting median code separately
finally implement nanmad() function