Skip to content

Commit 1fdf5c4

Browse files
committed
Fix pow(a,b) overload resolution under llvm19
1 parent 9b1f08b commit 1fdf5c4

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

stan/math/fwd/fun/pow.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ inline std::complex<fvar<V>> pow(const fvar<V>& x, const std::complex<T>& y) {
193193
* @return first argument to the power of the second argument
194194
*/
195195
template <typename T, typename V, typename = require_arithmetic_t<T>>
196-
inline std::complex<fvar<V>> pow(T x, const std::complex<fvar<V>>& y) {
196+
inline std::complex<fvar<V>> pow(const T& x, const std::complex<fvar<V>>& y) {
197197
return internal::complex_pow(x, y);
198198
}
199199

stan/math/prim/fun/pow.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ inline auto pow(const T1& a, const T2& b) {
5959
* second argument.
6060
*/
6161
template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr,
62-
require_all_not_matrix_st<is_var, T1, T2>* = nullptr>
62+
require_all_not_matrix_st<is_var, T1, T2>* = nullptr,
63+
require_all_st_arithmetic<T1, T2>* = nullptr>
6364
inline auto pow(const T1& a, const T2& b) {
6465
return apply_scalar_binary(a, b, [](const auto& c, const auto& d) {
65-
using std::pow;
66-
return pow(c, d);
66+
return stan::math::pow(c, d);
6767
});
6868
}
6969
} // namespace math

stan/math/rev/fun/pow.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ inline std::complex<var> pow(const std::complex<var>& x, const var& y) {
319319
* @return first argument to the power of the second argument
320320
*/
321321
template <typename T, typename = require_arithmetic_t<T>>
322-
inline std::complex<var> pow(const std::complex<var>& x, T y) {
322+
inline std::complex<var> pow(const std::complex<var>& x, const T& y) {
323323
return internal::complex_pow(x, y);
324324
}
325325

@@ -382,7 +382,7 @@ inline std::complex<var> pow(const var& x, std::complex<T> y) {
382382
* @return first argument to the power of the second argument
383383
*/
384384
template <typename T, typename = require_arithmetic_t<T>>
385-
inline std::complex<var> pow(T x, const std::complex<var>& y) {
385+
inline std::complex<var> pow(const T& x, const std::complex<var>& y) {
386386
return internal::complex_pow(x, y);
387387
}
388388

@@ -401,6 +401,26 @@ inline std::complex<var> pow(const std::complex<var>& x, int y) {
401401
return internal::complex_pow(x, y);
402402
}
403403

404+
/**
405+
* Returns the elementwise raising of the first argument to the power of the
406+
* second argument.
407+
*
408+
* @tparam T1 type of first argument
409+
* @tparam T2 type of second argument
410+
* @param a first argument
411+
* @param b second argument
412+
* @return the elementwise raising of the first argument to the power of the
413+
* second argument.
414+
*/
415+
template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr,
416+
require_all_not_matrix_st<is_var, T1, T2>* = nullptr,
417+
require_any_not_st_arithmetic<T1, T2>* = nullptr>
418+
inline auto pow(const T1& a, const T2& b) {
419+
return apply_scalar_binary(a, b, [](const auto& c, const auto& d) {
420+
return stan::math::pow(c, d);
421+
});
422+
}
423+
404424
} // namespace math
405425
} // namespace stan
406426
#endif

0 commit comments

Comments
 (0)