diff --git a/include/boost/math/differentiation/autodiff_reverse.hpp b/include/boost/math/differentiation/autodiff_reverse.hpp index d6948705d..dc7b43521 100644 --- a/include/boost/math/differentiation/autodiff_reverse.hpp +++ b/include/boost/math/differentiation/autodiff_reverse.hpp @@ -6,12 +6,23 @@ #define BOOST_MATH_DIFFERENTIATION_AUTODIFF_HPP #include -#include + +#ifndef BOOST_MATH_ET_OFF +#define BOOST_MATH_ET_ON +#endif + +#ifdef BOOST_MATH_ET_ON +#include +#include +#else +#include +#include +#endif + #include #include #include #include -#include #include #include #include diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_operator_overloads.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_operator_expressions.hpp similarity index 68% rename from include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_operator_overloads.hpp rename to include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_operator_expressions.hpp index 1acb2439f..27a3fdd7d 100644 --- a/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_operator_overloads.hpp +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_operator_expressions.hpp @@ -268,148 +268,6 @@ struct const_div_by_expr }; /****************************************************************************************************************/ -template -mult_expr operator*( - const expression &lhs, - const expression &rhs) -{ - return mult_expr(lhs, rhs); -} - -/** @brief type promotion is handled by casting the numeric type to - * the type inside expression. This is to avoid converting the - * entire tape in case you have something like double * rvar - * */ -template::value>::type> -mult_const_expr operator*( - const expression &arg, const RealType2 &v) -{ - return mult_const_expr(arg, static_cast(v)); -} -template::value>::type> -mult_const_expr operator*( - const RealType2 &v, const expression &arg) -{ - return mult_const_expr(arg, static_cast(v)); -} -/****************************************************************************************************************/ -/* + */ -template -add_expr operator+( - const expression &lhs, - const expression &rhs) -{ - return add_expr(lhs, rhs); -} -template::value>::type> -add_const_expr operator+( - const expression &arg, const RealType2 &v) -{ - return add_const_expr(arg, static_cast(v)); -} -template::value>::type> -add_const_expr operator+( - const RealType2 &v, const expression &arg) -{ - return add_const_expr(arg, static_cast(v)); -} -/****************************************************************************************************************/ -/* - overload */ -/** @brief - * negation (-1.0*rvar) */ -template -mult_const_expr operator-( - const expression &arg) -{ - return mult_const_expr(arg, static_cast(-1.0)); -} - -/** @brief - * subtraction rvar-rvar */ -template -sub_expr operator-( - const expression &lhs, - const expression &rhs) -{ - return sub_expr(lhs, rhs); -} - -/** @brief - * subtraction float - rvar */ -template::value>::type> -add_const_expr operator-( - const expression &arg, const RealType2 &v) -{ - /* rvar - float = rvar + (-float) */ - return add_const_expr(arg, static_cast(-v)); -} - -/** @brief - * subtraction float - rvar - * @return add_expr> - */ -template::value>::type> -auto operator-(const RealType2 &v, const expression &arg) -{ - auto neg = -arg; - return neg + static_cast(v); -} -/****************************************************************************************************************/ -/* / */ -template -div_expr operator/( - const expression &lhs, - const expression &rhs) -{ - return div_expr(lhs, rhs); -} - -template::value>::type> -const_div_by_expr operator/( - const RealType2 &v, const expression &arg) -{ - return const_div_by_expr(arg, static_cast(v)); -} - -template::value>::type> -div_by_const_expr operator/( - const expression &arg, const RealType2 &v) -{ - return div_by_const_expr(arg, static_cast(v)); -} - } // namespace reverse_mode } // namespace differentiation } // namespace math diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_ops_et.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_ops_et.hpp new file mode 100644 index 000000000..4767d1703 --- /dev/null +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_ops_et.hpp @@ -0,0 +1,160 @@ +// Copyright Maksym Zhelyenzyakov 2025-2026. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#ifndef REVERSE_MODE_AUTODIFF_BASIC_OPS_ET_HPP +#define REVERSE_MODE_AUTODIFF_BASIC_OPS_ET_HPP + +#include +namespace boost { +namespace math { +namespace differentiation { +namespace reverse_mode { +template +mult_expr operator*( + const expression &lhs, + const expression &rhs) +{ + return mult_expr(lhs, rhs); +} + +/** @brief type promotion is handled by casting the numeric type to + * the type inside expression. This is to avoid converting the + * entire tape in case you have something like double * rvar + * */ +template::value>::type> +mult_const_expr operator*( + const expression &arg, const RealType2 &v) +{ + return mult_const_expr(arg, static_cast(v)); +} +template::value>::type> +mult_const_expr operator*( + const RealType2 &v, const expression &arg) +{ + return mult_const_expr(arg, static_cast(v)); +} +/****************************************************************************************************************/ +/* + */ +template +add_expr operator+( + const expression &lhs, + const expression &rhs) +{ + return add_expr(lhs, rhs); +} +template::value>::type> +add_const_expr operator+( + const expression &arg, const RealType2 &v) +{ + return add_const_expr(arg, static_cast(v)); +} +template::value>::type> +add_const_expr operator+( + const RealType2 &v, const expression &arg) +{ + return add_const_expr(arg, static_cast(v)); +} +/****************************************************************************************************************/ +/* - overload */ +/** @brief + * negation (-1.0*rvar) */ +template +mult_const_expr operator-( + const expression &arg) +{ + return mult_const_expr(arg, static_cast(-1.0)); +} + +/** @brief + * subtraction rvar-rvar */ +template +sub_expr operator-( + const expression &lhs, + const expression &rhs) +{ + return sub_expr(lhs, rhs); +} + +/** @brief + * subtraction float - rvar */ +template::value>::type> +add_const_expr operator-( + const expression &arg, const RealType2 &v) +{ + /* rvar - float = rvar + (-float) */ + return add_const_expr(arg, static_cast(-v)); +} + +/** @brief + * subtraction float - rvar + * @return add_expr> + */ +template::value>::type> +auto operator-(const RealType2 &v, const expression &arg) +{ + auto neg = -arg; + return neg + static_cast(v); +} +/****************************************************************************************************************/ +/* / */ +template +div_expr operator/( + const expression &lhs, + const expression &rhs) +{ + return div_expr(lhs, rhs); +} + +template::value>::type> +const_div_by_expr operator/( + const RealType2 &v, const expression &arg) +{ + return const_div_by_expr(arg, static_cast(v)); +} + +template::value>::type> +div_by_const_expr operator/( + const expression &arg, const RealType2 &v) +{ + return div_by_const_expr(arg, static_cast(v)); +} +} // namespace reverse_mode +} // namespace differentiation +} // namespace math +} // namespace boost + +#endif // REVERSE_MODE_AUTODIFF_BASIC_OPS_ET_HPP diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_ops_no_et.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_ops_no_et.hpp new file mode 100644 index 000000000..21f8cf82a --- /dev/null +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_basic_ops_no_et.hpp @@ -0,0 +1,154 @@ +// Copyright Maksym Zhelyenzyakov 2025-2026. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#ifndef REVERSE_MODE_AUTODIFF_BASIC_OPS_NO_ET_HPP +#define REVERSE_MODE_AUTODIFF_BASIC_OPS_NO_ET_HPP +#include +namespace boost { +namespace math { +namespace differentiation { +namespace reverse_mode { + +template +rvar operator*(const expression &lhs, + const expression &rhs) +{ + return mult_expr(lhs, rhs); +} + +/** @brief type promotion is handled by casting the numeric type to + * the type inside expression. This is to avoid converting the + * entire tape in case you have something like double * rvar + * */ +template::value>::type> +rvar operator*(const expression &arg, + const RealType2 &v) +{ + return mult_const_expr(arg, static_cast(v)); +} +template::value>::type> +rvar operator*(const RealType2 &v, + const expression &arg) +{ + return mult_const_expr(arg, static_cast(v)); +} +/****************************************************************************************************************/ +/* + */ +template +rvar operator+(const expression &lhs, + const expression &rhs) +{ + return add_expr(lhs, rhs); +} +template::value>::type> +rvar operator+(const expression &arg, + const RealType2 &v) +{ + return add_const_expr(arg, static_cast(v)); +} +template::value>::type> +rvar operator+(const RealType2 &v, + const expression &arg) +{ + return add_const_expr(arg, static_cast(v)); +} +/****************************************************************************************************************/ +/* - overload */ +/** @brief + * negation (-1.0*rvar) */ +template +rvar operator-(const expression &arg) +{ + return mult_const_expr(arg, static_cast(-1.0)); +} + +/** @brief + * subtraction rvar-rvar */ +template +rvar operator-(const expression &lhs, + const expression &rhs) +{ + return sub_expr(lhs, rhs); +} + +/** @brief + * subtraction float - rvar */ +template::value>::type> +rvar operator-(const expression &arg, + const RealType2 &v) +{ + /* rvar - float = rvar + (-float) */ + return add_const_expr(arg, static_cast(-v)); +} + +/** @brief + * subtraction float - rvar + * @return add_expr> + */ +template::value>::type> +rvar operator-(const RealType2 &v, + const expression &arg) +{ + auto neg = -arg; + return neg + static_cast(v); +} +/****************************************************************************************************************/ +/* / */ +template +rvar operator/(const expression &lhs, + const expression &rhs) +{ + return div_expr(lhs, rhs); +} + +template::value>::type> +rvar operator/(const RealType2 &v, + const expression &arg) +{ + return const_div_by_expr(arg, static_cast(v)); +} + +template::value>::type> +rvar operator/(const expression &arg, + const RealType2 &v) +{ + return div_by_const_expr(arg, static_cast(v)); +} +} // namespace reverse_mode +} // namespace differentiation +} // namespace math +} // namespace boost +#endif diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_erf_overloads.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_erf_overloads.hpp index 8e6697ae5..37aa26f7b 100644 --- a/include/boost/math/differentiation/detail/reverse_mode_autodiff_erf_overloads.hpp +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_erf_overloads.hpp @@ -7,7 +7,13 @@ #include #include -#include + +#ifdef BOOST_MATH_ET_ON +#include +#else +#include +#endif + #include #include #include diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_et.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_et.hpp new file mode 100644 index 000000000..8ef304f3b --- /dev/null +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_et.hpp @@ -0,0 +1,275 @@ +// Copyright Maksym Zhelyenzyakov 2025-2026. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#ifndef REVERSE_MODE_AUTODIFF_STL_ET_HPP +#define REVERSE_MODE_AUTODIFF_STL_ET_HPP + +#include +namespace boost { +namespace math { +namespace differentiation { +namespace reverse_mode { + +template +fabs_expr fabs(const expression &arg) +{ + return fabs_expr(arg, static_cast(0.0)); +} +template +auto abs(const expression &arg) +{ + return fabs(arg); +} +template +ceil_expr ceil(const expression &arg) +{ + return ceil_expr(arg, static_cast(0.0)); +} +template +floor_expr floor( + const expression &arg) +{ + return floor_expr(arg, static_cast(0.0)); +} + +template +exp_expr exp(const expression &arg) +{ + return exp_expr(arg, static_cast(0.0)); +} + +template +pow_expr pow( + const expression &lhs, + const expression &rhs) +{ + return pow_expr(lhs, rhs); +} + +template::value>::type> +expr_pow_float_expr pow( + const expression &arg, const RealType2 &v) +{ + return expr_pow_float_expr(arg, static_cast(v)); +}; + +template +float_pow_expr_expr pow( + const RealType &v, const expression &arg) +{ + return float_pow_expr_expr(arg, v); +}; + +template +log_expr log(const expression &arg) +{ + return log_expr(arg, static_cast(0.0)); +}; + +template +sqrt_expr sqrt(const expression &arg) +{ + return sqrt_expr(arg, static_cast(0.0)); +}; + +template +auto frexp(const expression &arg, int *i) +{ + BOOST_MATH_STD_USING + frexp(arg.evaluate(), i); + return arg / pow(static_cast(2.0), *i); +} + +template +auto ldexp(const expression &arg, const int &i) +{ + BOOST_MATH_STD_USING + return arg * pow(static_cast(2.0), i); +} + +template +cos_expr cos(const expression &arg) +{ + return cos_expr(arg, static_cast(0.0)); +}; + +template +sin_expr sin(const expression &arg) +{ + return sin_expr(arg, static_cast(0.0)); +}; + +template +tan_expr tan(const expression &arg) +{ + return tan_expr(arg, static_cast(0.0)); +}; + +template +acos_expr acos(const expression &arg) +{ + return acos_expr(arg, static_cast(0.0)); +}; + +template +asin_expr asin(const expression &arg) +{ + return asin_expr(arg, static_cast(0.0)); +}; + +template +atan_expr atan(const expression &arg) +{ + return atan_expr(arg, static_cast(0.0)); +}; + +template +atan2_expr atan2( + const expression &lhs, + const expression &rhs) +{ + return atan2_expr(lhs, rhs); +} + +template +atan2_right_float_expr atan2( + const expression &arg, const RealType &v) +{ + return atan2_right_float_expr(arg, v); +}; + +template +atan2_left_float_expr atan2( + const RealType &v, const expression &arg) +{ + return atan2_left_float_expr(arg, v); +}; + +template +trunc_expr trunc( + const expression &arg) +{ + return trunc_expr(arg, static_cast(0.0)); +} + +template +auto fmod(const expression &lhs, + const expression &rhs) +{ + return fmod_expr(lhs, rhs); +} + +template +auto fmod(const expression &lhs, const RealType rhs) +{ + return fmod_right_float_expr(lhs, rhs); +} + +template +auto fmod(const RealType lhs, const expression &rhs) +{ + return fmod_left_float_expr(rhs, lhs); +} + +template +round_expr round( + const expression &arg) +{ + return round_expr(arg, static_cast(0.0)); +} + +template +int iround(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return iround(tmp.item()); +} +template +long lround(const expression &arg) +{ + BOOST_MATH_STD_USING + rvar tmp = arg.evaluate(); + return lround(tmp.item()); +} + +template +long long llround(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return llround(tmp.item()); +} + +template +int itrunc(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return itrunc(tmp.item()); +} + +template +long ltrunc(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return ltrunc(tmp.item()); +} + +template +long long lltrunc(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return lltrunc(tmp.item()); +} + +template +sinh_expr sinh(const expression &arg) +{ + return sinh_expr(arg, static_cast(0.0)); +} + +template +cosh_expr cosh(const expression &arg) +{ + return cosh_expr(arg, static_cast(0.0)); +} + +template +tanh_expr tanh(const expression &arg) +{ + return tanh_expr(arg, static_cast(0.0)); +} + +template +log10_expr log10( + const expression &arg) +{ + return log10_expr(arg, static_cast(0.0)); +} +template +asinh_expr asinh( + const expression &arg) +{ + return asinh_expr(arg, static_cast(0.0)); +} +template +acosh_expr acosh( + const expression &arg) +{ + return acosh_expr(arg, static_cast(0.0)); +} +template +atanh_expr atanh( + const expression &arg) +{ + return atanh_expr(arg, static_cast(0.0)); +} +} // namespace reverse_mode +} // namespace differentiation +} // namespace math +} // namespace boost + +#endif diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_overloads.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_expressions.hpp similarity index 76% rename from include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_overloads.hpp rename to include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_expressions.hpp index aa8716d4a..0acc2e6b0 100644 --- a/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_overloads.hpp +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_expressions.hpp @@ -5,7 +5,13 @@ #ifndef REVERSE_MODE_AUTODIFF_STL_OVERLOADS #define REVERSE_MODE_AUTODIFF_STL_OVERLOADS /* stl support : expressions */ -#include + +#ifdef BOOST_MATH_ET_ON +#include +#else +#include +#endif + #include #include #include @@ -836,249 +842,7 @@ struct fmod_right_float_expr } }; /**************************************************************************************************/ -template -fabs_expr fabs(const expression &arg) -{ - return fabs_expr(arg, static_cast(0.0)); -} -template -auto abs(const expression &arg) -{ - return fabs(arg); -} -template -ceil_expr ceil(const expression &arg) -{ - return ceil_expr(arg, static_cast(0.0)); -} -template -floor_expr floor(const expression &arg) -{ - return floor_expr(arg, static_cast(0.0)); -} -template -exp_expr exp(const expression &arg) -{ - return exp_expr(arg, static_cast(0.0)); -} - -template -pow_expr pow(const expression &lhs, - const expression &rhs) -{ - return pow_expr(lhs, rhs); -} - -template::value>::type> -expr_pow_float_expr pow( - const expression &arg, const RealType2 &v) -{ - return expr_pow_float_expr(arg, static_cast(v)); -}; - -template -float_pow_expr_expr pow(const RealType &v, const expression &arg) -{ - return float_pow_expr_expr(arg, v); -}; - -template -log_expr log(const expression &arg) -{ - return log_expr(arg, static_cast(0.0)); -}; - -template -sqrt_expr sqrt(const expression &arg) -{ - return sqrt_expr(arg, static_cast(0.0)); -}; - -template -auto frexp(const expression &arg, int *i) -{ - BOOST_MATH_STD_USING - frexp(arg.evaluate(), i); - return arg / pow(static_cast(2.0), *i); -} - -template -auto ldexp(const expression &arg, const int &i) -{ - BOOST_MATH_STD_USING - return arg * pow(static_cast(2.0), i); -} - -template -cos_expr cos(const expression &arg) -{ - return cos_expr(arg, static_cast(0.0)); -}; - -template -sin_expr sin(const expression &arg) -{ - return sin_expr(arg, static_cast(0.0)); -}; - -template -tan_expr tan(const expression &arg) -{ - return tan_expr(arg, static_cast(0.0)); -}; - -template -acos_expr acos(const expression &arg) -{ - return acos_expr(arg, static_cast(0.0)); -}; - -template -asin_expr asin(const expression &arg) -{ - return asin_expr(arg, static_cast(0.0)); -}; - -template -atan_expr atan(const expression &arg) -{ - return atan_expr(arg, static_cast(0.0)); -}; - -template -atan2_expr atan2(const expression &lhs, - const expression &rhs) -{ - return atan2_expr(lhs, rhs); -} - -template -atan2_right_float_expr atan2(const expression &arg, const RealType &v) -{ - return atan2_right_float_expr(arg, v); -}; - -template -atan2_left_float_expr atan2(const RealType &v, const expression &arg) -{ - return atan2_left_float_expr(arg, v); -}; - -template -trunc_expr trunc(const expression &arg) -{ - return trunc_expr(arg, static_cast(0.0)); -} - -template -auto fmod(const expression &lhs, const expression &rhs) -{ - return fmod_expr(lhs, rhs); -} - -template -auto fmod(const expression &lhs, const RealType rhs) -{ - return fmod_right_float_expr(lhs, rhs); -} - -template -auto fmod(const RealType lhs, const expression &rhs) -{ - return fmod_left_float_expr(rhs, lhs); -} - -template -round_expr round(const expression &arg) -{ - return round_expr(arg, static_cast(0.0)); -} - -template -int iround(const expression &arg) -{ - rvar tmp = arg.evaluate(); - return iround(tmp.item()); -} -template -long lround(const expression &arg) -{ - BOOST_MATH_STD_USING - rvar tmp = arg.evaluate(); - return lround(tmp.item()); -} - -template -long long llround(const expression &arg) -{ - rvar tmp = arg.evaluate(); - return llround(tmp.item()); -} - -template -int itrunc(const expression &arg) -{ - rvar tmp = arg.evaluate(); - return itrunc(tmp.item()); -} - -template -long ltrunc(const expression &arg) -{ - rvar tmp = arg.evaluate(); - return ltrunc(tmp.item()); -} - -template -long long lltrunc(const expression &arg) -{ - rvar tmp = arg.evaluate(); - return lltrunc(tmp.item()); -} - -template -sinh_expr sinh(const expression &arg) -{ - return sinh_expr(arg, static_cast(0.0)); -} - -template -cosh_expr cosh(const expression &arg) -{ - return cosh_expr(arg, static_cast(0.0)); -} - -template -tanh_expr tanh(const expression &arg) -{ - return tanh_expr(arg, static_cast(0.0)); -} - -template -log10_expr log10(const expression &arg) -{ - return log10_expr(arg, static_cast(0.0)); -} -template -asinh_expr asinh(const expression &arg) -{ - return asinh_expr(arg, static_cast(0.0)); -} -template -acosh_expr acosh(const expression &arg) -{ - return acosh_expr(arg, static_cast(0.0)); -} -template -atanh_expr atanh(const expression &arg) -{ - return atanh_expr(arg, static_cast(0.0)); -} } // namespace reverse_mode } // namespace differentiation } // namespace math diff --git a/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_no_et.hpp b/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_no_et.hpp new file mode 100644 index 000000000..15498a127 --- /dev/null +++ b/include/boost/math/differentiation/detail/reverse_mode_autodiff_stl_no_et.hpp @@ -0,0 +1,266 @@ +// Copyright Maksym Zhelyenzyakov 2025-2026. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) +#ifndef REVERSE_MODE_AUTODIFF_STL_NO_ET_HPP +#define REVERSE_MODE_AUTODIFF_STL_NO_ET_HPP + +#include +namespace boost { +namespace math { +namespace differentiation { +namespace reverse_mode { + +template +rvar fabs(const expression &arg) +{ + return fabs_expr(arg, static_cast(0.0)); +} +template +rvar abs(const expression &arg) +{ + return fabs(arg); +} +template +rvar ceil(const expression &arg) +{ + return ceil_expr(arg, static_cast(0.0)); +} +template +rvar floor(const expression &arg) +{ + return floor_expr(arg, static_cast(0.0)); +} + +template +rvar exp(const expression &arg) +{ + return exp_expr(arg, static_cast(0.0)); +} + +template +rvar pow(const expression &lhs, + const expression &rhs) +{ + return pow_expr(lhs, rhs); +} + +template::value>::type> +rvar pow(const expression &arg, + const RealType2 &v) +{ + return expr_pow_float_expr(arg, static_cast(v)); +}; + +template +rvar pow(const RealType &v, + const expression &arg) +{ + return float_pow_expr_expr(arg, v); +}; + +template +rvar log(const expression &arg) +{ + return log_expr(arg, static_cast(0.0)); +}; + +template +rvar sqrt(const expression &arg) +{ + return sqrt_expr(arg, static_cast(0.0)); +}; + +template +rvar frexp(const expression &arg, int *i) +{ + BOOST_MATH_STD_USING + frexp(arg.evaluate(), i); + return arg / pow(static_cast(2.0), *i); +} + +template +auto ldexp(const expression &arg, const int &i) +{ + BOOST_MATH_STD_USING + return arg * pow(static_cast(2.0), i); +} + +template +rvar cos(const expression &arg) +{ + return cos_expr(arg, static_cast(0.0)); +}; + +template +rvar sin(const expression &arg) +{ + return sin_expr(arg, static_cast(0.0)); +}; + +template +rvar tan(const expression &arg) +{ + return tan_expr(arg, static_cast(0.0)); +}; + +template +rvar acos(const expression &arg) +{ + return acos_expr(arg, static_cast(0.0)); +}; + +template +rvar asin(const expression &arg) +{ + return asin_expr(arg, static_cast(0.0)); +}; + +template +rvar atan(const expression &arg) +{ + return atan_expr(arg, static_cast(0.0)); +}; + +template +rvar atan2(const expression &lhs, + const expression &rhs) +{ + return atan2_expr(lhs, rhs); +} + +template +rvar atan2(const expression &arg, + const RealType &v) +{ + return atan2_right_float_expr(arg, v); +}; + +template +rvar atan2(const RealType &v, + const expression &arg) +{ + return atan2_left_float_expr(arg, v); +}; + +template +rvar trunc(const expression &arg) +{ + return trunc_expr(arg, static_cast(0.0)); +} + +template +auto fmod(const expression &lhs, + const expression &rhs) +{ + return fmod_expr(lhs, rhs); +} + +template +auto fmod(const expression &lhs, const RealType rhs) +{ + return fmod_right_float_expr(lhs, rhs); +} + +template +auto fmod(const RealType lhs, const expression &rhs) +{ + return fmod_left_float_expr(rhs, lhs); +} + +template +rvar round(const expression &arg) +{ + return round_expr(arg, static_cast(0.0)); +} + +template +int iround(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return iround(tmp.item()); +} +template +long lround(const expression &arg) +{ + BOOST_MATH_STD_USING + rvar tmp = arg.evaluate(); + return lround(tmp.item()); +} + +template +long long llround(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return llround(tmp.item()); +} + +template +int itrunc(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return itrunc(tmp.item()); +} + +template +long ltrunc(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return ltrunc(tmp.item()); +} + +template +long long lltrunc(const expression &arg) +{ + rvar tmp = arg.evaluate(); + return lltrunc(tmp.item()); +} + +template +rvar sinh(const expression &arg) +{ + return sinh_expr(arg, static_cast(0.0)); +} + +template +rvar cosh(const expression &arg) +{ + return cosh_expr(arg, static_cast(0.0)); +} + +template +rvar tanh(const expression &arg) +{ + return tanh_expr(arg, static_cast(0.0)); +} + +template +rvar log10(const expression &arg) +{ + return log10_expr(arg, static_cast(0.0)); +} +template +rvar asinh(const expression &arg) +{ + return asinh_expr(arg, static_cast(0.0)); +} +template +rvar acosh(const expression &arg) +{ + return acosh_expr(arg, static_cast(0.0)); +} +template +rvar atanh(const expression &arg) +{ + return atanh_expr(arg, static_cast(0.0)); +} +} // namespace reverse_mode +} // namespace differentiation +} // namespace math +} // namespace boost + +#endif