added NaN test for col (based on Peter Li's agrad-rev test code)
added NaN test for row (based on Peter Li's agrad-rev test code)