1 #ifndef STAN_MATH_PRIM_FUN_IMAG_HPP 2 #define STAN_MATH_PRIM_FUN_IMAG_HPP 3 4 #include <stan/math/prim/meta.hpp> 5 #include <complex> 6 7 namespace stan { 8 namespace math { 9 10 /** 11 * Return the imaginary component of the complex argument. 12 * 13 * @tparam T value type of complex argument 14 * @param[in] z complex value whose imaginary component is extracted 15 * @return imaginary component of argument 16 */ 17 template <typename T, require_autodiff_t<T>> 18 T imag(const std::complex<T>& z) { 19 return z.imag(); 20 } 21 22 } // namespace math 23 } // namespace stan 24 25 #endif 26