/
Eigen_ScalarBinaryOpTraits.hpp
38 lines (36 loc) · 1.54 KB
/
Eigen_ScalarBinaryOpTraits.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef STAN_MATH_PRIM_MAT_META_EIGEN_SCALARBINARYOPTRAITS_HPP
#define STAN_MATH_PRIM_MAT_META_EIGEN_SCALARBINARYOPTRAITS_HPP
#include <stan/math/prim/scal/meta/is_arith_like.hpp>
#include <stan/math/prim/scal/meta/is_complex.hpp>
#include <stan/math/prim/scal/meta/return_type.hpp>
#include <stan/math/prim/scal/meta/rm_complex.hpp>
#include <stan/math/prim/scal/meta/rm_zeroing.hpp>
#include <Eigen/Dense>
#include <complex>
#include <type_traits>
namespace Eigen {
/// @cond DO_NOT_DOCUMENT
// Eigen scalar op traits specialization for complex variables
template <class T1, class T2, template <class, class> class OP>
struct ScalarBinaryOpTraits<
T1,
std::enable_if_t<
// !VectorBlock !is_eigen
(stan::is_complex<T1>::value || stan::is_arith_like<T1>::value)
&& (stan::is_complex<T2>::value || stan::is_arith_like<T2>::value)
&& !std::is_same<T1, T2>::value && // avoid Eigen's template
((stan::is_complex<T1>::value && // next boolean avoids Eigen
!std::is_same<stan::rm_complex_t<T1>,
stan::rm_zeroing_t<T2>>::value)
|| (stan::is_complex<T2>::value && // next bool avoids Eigen
!std::is_same<stan::rm_zeroing_t<T1>,
stan::rm_complex_t<T2>>::value)),
T2>,
OP<T1, T2>> {
typedef std::complex<typename stan::return_type<stan::rm_complex_t<T1>,
stan::rm_complex_t<T2>>::type>
ReturnType;
};
/// @endcond
} // namespace Eigen
#endif