#ifndef STAN_MATH_FWD_MAT_FUN_EIGEN_NUMTRAITS_HPP #define STAN_MATH_FWD_MAT_FUN_EIGEN_NUMTRAITS_HPP #include #include #include #include namespace Eigen { /** * Numerical traits template override for Eigen for automatic * gradient variables. */ template struct NumTraits> : GenericNumTraits> { enum { /** * stan::math::fvar requires initialization */ RequireInitialization = 1, /** * twice the cost to copy a double */ ReadCost = 2 * NumTraits::ReadCost, /** * 2 * AddCost *
* (a + b) = a + b *
* (a + b)' = a' + b' */ AddCost = 2 * NumTraits::AddCost, /** * 3 * MulCost + AddCost *
* (a * b) = a * b *
* (a * b)' = a' * b + a * b' */ MulCost = 3 * NumTraits::MulCost + NumTraits::AddCost }; /** * Return the number of decimal digits that can be represented * without change. Delegates to * std::numeric_limits::digits10(). */ static int digits10() { return std::numeric_limits::digits10; } }; /** * Scalar product traits specialization for Eigen for forward-mode * autodiff variables. */ template struct ScalarBinaryOpTraits, double, BinaryOp> { typedef stan::math::fvar ReturnType; }; /** * Scalar product traits specialization for Eigen for forward-mode * autodiff variables. */ template struct ScalarBinaryOpTraits, BinaryOp> { typedef stan::math::fvar ReturnType; }; } // namespace Eigen #endif