Automatic Differentiation
 
Loading...
Searching...
No Matches
to_complex.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_TO_COMPLEX_HPP
2#define STAN_MATH_PRIM_FUN_TO_COMPLEX_HPP
3
6#include <complex>
7
8namespace stan {
9namespace math {
10
21template <typename T = double, typename S = double,
22 require_all_not_container_t<T, S>* = nullptr>
23constexpr inline std::complex<stan::real_return_t<T, S>> to_complex(
24 const T& re = 0, const S& im = 0) {
25 return std::complex<stan::real_return_t<T, S>>(re, im);
26}
27
38template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr,
39 require_all_st_stan_scalar<T1, T2>* = nullptr>
40inline auto to_complex(T1&& re, T2&& im) {
42 [](auto&& c, auto&& d) {
43 return stan::math::to_complex(std::forward<decltype(c)>(c),
44 std::forward<decltype(d)>(d));
45 },
46 std::forward<T1>(re), std::forward<T2>(im));
47}
48
49} // namespace math
50} // namespace stan
51
52#endif
constexpr std::complex< stan::real_return_t< T, S > > to_complex(const T &re=0, const S &im=0)
Return a complex value from a real component and an imaginary component.
auto apply_scalar_binary(F &&f, T1 &&x, T2 &&y)
Base template function for vectorization of binary scalar functions defined by applying a functor to ...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...