1 #ifndef STAN_MATH_PRIM_FUN_TO_COMPLEX_HPP 2 #define STAN_MATH_PRIM_FUN_TO_COMPLEX_HPP 3 4 #include <stan/math/prim/meta.hpp> 5 #include <stan/math/prim/meta/return_type.hpp> 6 #include <complex> 7 8 namespace stan { 9 namespace math { 10 11 /** 12 * Return a complex value from a real component and an imaginary component. 13 * Default values for both components is 0. 14 * 15 * @tparam T type of real component 16 * @tparam S type of imaginary component 17 * @param[in] re real component (default = 0) 18 * @param[in] im imaginary component (default = 0) 19 * @return complex value with specified real and imaginary components 20 */ 21 template <typename T = double, typename S = double> to_complex(const T & re=0,const S & im=0)22constexpr inline std::complex<stan::real_return_t<T, S>> to_complex( 23 const T& re = 0, const S& im = 0) { 24 return std::complex<stan::real_return_t<T, S>>(re, im); 25 } 26 27 } // namespace math 28 } // namespace stan 29 30 #endif 31