5 #ifndef LODESTAR_REIMTOCOMPLEXBLOCK_HPP
6 #define LODESTAR_REIMTOCOMPLEXBLOCK_HPP
8 #include "Lodestar/blocks/Block.hpp"
12 #include "Eigen/Dense"
17 template<
typename TType,
typename SFINAE =
void>
24 static_assert(!::std::is_same<TType, TType>::value,
25 "ReImToComplexBlock not defined for this type.");
28 template<
typename TType>
30 ::std::is_same<TType, float>::value ||
31 ::std::is_same<TType, double>::value ||
32 ::std::is_same<TType, long double>::value)>
::type>
35 ::std::tuple<TType, TType>,
36 ::std::tuple<::std::complex<TType>>,
42 typename ::std::enable_if<(
43 ::std::is_same<TType, float>::value ||
44 ::std::is_same<TType, double>::value ||
45 ::std::is_same<TType, long double>::value)>::
type
50 ::std::tuple<TType, TType>,
51 ::std::tuple<::std::complex<TType>>,
55 static const ::std::complex<TType> j;
64 return this->
template i<0>();
69 this->
template i<0>() = re;
70 return this->
template i<0>();
75 return this->
template i<0>();
80 return this->
template i<1>();
85 this->
template i<1>() = im;
86 return this->
template i<1>();
91 return this->
template i<1>();
97 this->equation = ::std::bind(
98 &type::triggerFunction,
100 ::std::placeholders::_1
104 void triggerFunction(
Base &b)
106 b.template o<0>().object.real(b.template i<0>());
107 b.template o<0>().object.imag(b.template i<1>());
111 template<
typename TType>
113 ::std::is_same<TType, float>::value ||
114 ::std::is_same<TType, double>::value ||
115 ::std::is_same<TType, long double>::value)>::type>::j =
116 ::std::complex<TType>{0, 1};
118 template<
typename TScalar,
int TRows,
int TCols>
120 ::std::is_same<TScalar, float>::value ||
121 ::std::is_same<TScalar, double>::value ||
122 ::std::is_same<TScalar, long double>::value)>::
type> :
124 ::std::tuple<Eigen::Matrix<TScalar, TRows, TCols>, Eigen::Matrix<TScalar, TRows, TCols>>,
125 ::std::tuple<Eigen::Matrix<::std::complex<TScalar>, TRows, TCols>>,
130 Eigen::Matrix<TScalar, TRows, TCols>,
131 typename ::std::enable_if<(
132 ::std::is_same<TScalar, float>::value ||
133 ::std::is_same<TScalar, double>::value ||
134 ::std::is_same<TScalar, long double>::value)
139 ::std::tuple<Eigen::Matrix<TScalar, TRows, TCols>, Eigen::Matrix<TScalar, TRows, TCols>>,
140 ::std::tuple<Eigen::Matrix<::std::complex<TScalar>, TRows, TCols>>,
144 static const ::std::complex<TScalar> j;
146 using RealMatrix = Eigen::Matrix<TScalar, TRows, TCols>;
155 return this->
template i<0>();
160 this->
template i<0>() = re;
161 return this->
template i<0>();
166 return this->
template i<0>();
171 return this->
template i<1>();
176 this->
template i<1>() = im;
177 return this->
template i<1>();
182 return this->
template i<1>();
188 this->equation = ::std::bind(
189 &type::triggerFunction,
191 ::std::placeholders::_1
195 void triggerFunction(
Base &b)
197 b.template o<0>().object = real().object +
198 ::std::complex<TScalar>(0, 1) *
203 template<
typename TScalar,
int TRows,
int TCols>
205 ::std::is_same<TScalar, float>::value ||
206 ::std::is_same<TScalar, double>::value ||
207 ::std::is_same<TScalar, long double>::value)>::type>::j =
208 ::std::complex<TScalar>{0, 1};
211 template<
typename TType,
typename SFINAE>
215 static constexpr
const bool directFeedthrough =
true;
218 using Base =
typename type::Base;
220 static const constexpr
int kIns = type::Base::kIns;
221 static const constexpr
int kOuts = type::Base::kOuts;
222 static const constexpr
int kPars = type::Base::kPars;
228 #endif //LODESTAR_REIMTOCOMPLEXBLOCK_HPP