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
7#include <cmath>
8#include <complex>
9
10namespace stan {
11namespace math {
12
13namespace internal {
14
25template <typename U, typename V>
26inline complex_return_t<U, V> complex_pow(const U& x, const V& y) {
27 return exp(y * log(x));
28}
29} // namespace internal
30
42template <typename T1, typename T2,
44 disjunction<is_complex<T1>, std::is_arithmetic<T1>>,
45 disjunction<is_complex<T2>, std::is_arithmetic<T2>>>* = nullptr>
46inline auto pow(const T1& a, const T2& b) {
47 return std::pow(a, b);
48}
49
61template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr,
62 require_all_not_matrix_st<is_var, T1, T2>* = nullptr>
63inline auto pow(const T1& a, const T2& b) {
64 return apply_scalar_binary(a, b, [](const auto& c, const auto& d) {
65 using std::pow;
66 return pow(c, d);
67 });
68}
69} // namespace math
70} // namespace stan
71#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:26
fvar< T > log(const fvar< T > &x)
Definition log.hpp:15
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
Definition pow.hpp:19
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
std::enable_if_t< math::conjunction< Checks... >::value > require_all_t
If all conditions are true, template is enabled Returns a type void if all conditions are true and ot...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9