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(const T1& re, const T2& im) {
41 return apply_scalar_binary(re, im, [&](const auto& c, const auto& d) {
42 return stan::math::to_complex(c, d);
43 });
44}
45
46} // namespace math
47} // namespace stan
48
49#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(const T1 &x, const T2 &y, const F &f)
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 ...