Automatic Differentiation
 
Loading...
Searching...
No Matches
pow.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_POW_HPP
2#define STAN_MATH_PRIM_FUN_POW_HPP
3
8#include <cmath>
9#include <complex>
10
11namespace stan {
12namespace math {
13
14namespace internal {
15
26template <typename U, typename V>
27inline complex_return_t<U, V> complex_pow(const U& x, const V& y) {
28 return exp(y * log(x));
29}
30} // namespace internal
31
43template <typename T1, typename T2, require_arithmetic_t<T1>* = nullptr,
44 require_arithmetic_t<T2>* = nullptr>
45inline auto pow(const std::complex<T1>& a, const std::complex<T2>& b) {
46 return std::pow(a, b);
47}
48
49template <typename T1, typename T2, require_arithmetic_t<T1>* = nullptr,
50 require_arithmetic_t<T2>* = nullptr>
51inline auto pow(const T1& a, const std::complex<T2>& b) {
52 return std::pow(a, b);
53}
54
55template <typename T1, typename T2, require_arithmetic_t<T1>* = nullptr,
56 require_arithmetic_t<T2>* = nullptr>
57inline auto pow(const std::complex<T1>& a, const T2& b) {
58 return std::pow(a, b);
59}
60
61template <typename T1, typename T2, require_arithmetic_t<T1>* = nullptr,
62 require_arithmetic_t<T2>* = nullptr>
63inline auto pow(const T1& a, const T2& b) {
64 return std::pow(a, b);
65}
77template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr,
78 require_all_not_matrix_st<is_var, T1, T2>* = nullptr,
79 require_all_arithmetic_t<base_type_t<T1>, base_type_t<T2>>* = nullptr>
80inline auto pow(const T1& a, const T2& b) {
82 a, b, [](const auto& c, const auto& d) { return stan::math::pow(c, d); });
83}
84} // namespace math
85} // namespace stan
86#endif
std::complex< real_return_t< Ts... > > complex_return_t
Convenience type to calculate the complex return type, which wraps std::complex around the return typ...
complex_return_t< U, V > complex_pow(const U &x, const V &y)
Return the first argument raised to the power of the second argument.
Definition pow.hpp:27
auto pow(const T1 &x1, const T2 &x2)
Definition pow.hpp:32
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
auto apply_scalar_binary(const T1 &x, const T2 &y, const F &f)
Base template function for vectorization of binary scalar functions defined by applying a functor to ...
fvar< T > exp(const fvar< T > &x)
Definition exp.hpp:13
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...