diff --git a/include/teqp/math/quadrature.hpp b/include/teqp/math/quadrature.hpp index 685dd76f9e0025e2e2a04cee2c335287d822a251..3b0433c537e1ad7c5610ac190e1c76c07aa1476c 100644 --- a/include/teqp/math/quadrature.hpp +++ b/include/teqp/math/quadrature.hpp @@ -59,6 +59,7 @@ inline auto quad(const std::function<T(double)>& F, const double& a, const doubl double arg = (b-a)/2.0*x[i] + (a+b)/2.0; summer += w[i]*F(arg); } - return (b-a)/2.0*summer; + T retval = (b-a)/2.0*summer; // Forces a flattening if T is an autodiff type + return retval; } }