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