Fix logic bug in adjoint computations of trace_gen_quad_form.