added NaN test for trace_quad_form