@@ -18,24 +18,27 @@ namespace stan {
1818namespace math {
1919/*
2020 *
21- * @tparam T1 Either an `fvar`, `arithmetic`, or `complex` type with an inner `fvar` or `arithmetic` type.
22- * @tparam T2 Either a `fvar`, `arithmetic`, or `complex` type with an inner `fvar` or `arithmetic` type.
21+ * @tparam T1 Either an `fvar`, `arithmetic`, or `complex` type with an inner
22+ * `fvar` or `arithmetic` type.
23+ * @tparam T2 Either a `fvar`, `arithmetic`, or `complex` type with an inner
24+ * `fvar` or `arithmetic` type.
2325 * @param x1 Base variable.
2426 * @param x2 Exponent variable.
2527 * @return Base raised to the exponent.
2628 */
27- template <typename T1, typename T2,
28- require_any_fvar_t <base_type_t <T1>, base_type_t <T2>>* = nullptr ,
29- require_all_stan_scalar_t <T1, T2>* = nullptr >
29+ template <typename T1, typename T2,
30+ require_any_fvar_t <base_type_t <T1>, base_type_t <T2>>* = nullptr ,
31+ require_all_stan_scalar_t <T1, T2>* = nullptr >
3032inline auto pow (const T1& x1, const T2& x2) {
3133 using std::log;
3234 using std::pow;
3335 if constexpr (is_complex<T1>::value || is_complex<T2>::value) {
3436 return internal::complex_pow (x1, x2);
3537 } else if constexpr (is_fvar<T1>::value && is_fvar<T2>::value) {
3638 auto pow_x1_x2 (stan::math::pow (x1.val_ , x2.val_ ));
37- return T1 (pow_x1_x2, (x2.d_ * stan::math::log (x1.val_ ) + x2.val_ * x1.d_ / x1.val_ )
38- * pow_x1_x2);
39+ return T1 (pow_x1_x2,
40+ (x2.d_ * stan::math::log (x1.val_ ) + x2.val_ * x1.d_ / x1.val_ )
41+ * pow_x1_x2);
3942 } else if constexpr (is_fvar<T2>::value) {
4043 auto u = stan::math::pow (x1, x2.val_ );
4144 return T2 (u, x2.d_ * stan::math::log (x1) * u);
@@ -59,10 +62,26 @@ inline auto pow(const T1& x1, const T2& x2) {
5962 if (x2 == 2.0 ) {
6063 return stan::math::square (x1);
6164 }
62- return T1 (stan::math::pow (x1.val_ , x2), x1.d_ * x2 * stan::math::pow (x1.val_ , x2 - 1 ));
65+ return T1 (stan::math::pow (x1.val_ , x2),
66+ x1.d_ * x2 * stan::math::pow (x1.val_ , x2 - 1 ));
6367 }
6468}
6569
70+ <<<<<<< HEAD
71+ =======
72+ // must uniquely match all pairs of:
73+ // { complex<fvar<V>>, complex<T>, fvar<V>, T }
74+ // with at least one fvar<V> and at least one complex, where T is arithmetic:
75+ // 1) complex<fvar<V>>, complex<fvar<V>>
76+ // 2) complex<fvar<V>>, complex<T>
77+ // 3) complex<fvar<V>>, fvar<V>
78+ // 4) complex<fvar<V>>, T
79+ // 5) complex<T>, complex<fvar<V>>
80+ // 6) complex<T>, fvar<V>
81+ // 7) fvar<V>, complex<fvar<V>>
82+ // 8) fvar<V>, complex<T>
83+ // 9) T, complex<fvar<V>>
84+ >>>>>>> origin/fix/pow-overload-resolution
6685
6786/* *
6887 * Returns the elementwise raising of the first argument to the power of the
0 commit comments