Automatic Differentiation
 
Loading...
Searching...
No Matches
get_imag.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_GET_IMAG_HPP
2#define STAN_MATH_PRIM_FUN_GET_IMAG_HPP
3
5#include <complex>
6
7namespace stan {
8namespace math {
9
17template <typename T>
18inline T get_imag(const std::complex<T>& z) {
19 return z.imag();
20}
21
29template <typename Eig, require_eigen_vt<is_complex, Eig>* = nullptr>
30inline auto get_imag(const Eig& z) {
31 return z.imag();
32}
33
41template <typename StdVec, require_std_vector_st<is_complex, StdVec>* = nullptr>
42inline auto get_imag(const StdVec& z) {
43 promote_scalar_t<base_type_t<StdVec>, StdVec> result(z.size());
44 std::transform(z.begin(), z.end(), result.begin(),
45 [](auto&& x) { return get_imag(x); });
46 return result;
47}
48
49} // namespace math
50} // namespace stan
51
52#endif
T get_imag(const std::complex< T > &z)
Return the imaginary component of the complex argument.
Definition get_imag.hpp:18
typename promote_scalar_type< std::decay_t< T >, std::decay_t< S > >::type promote_scalar_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...