mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 04:09:10 +08:00
Add generic implementation of conj_helper for custom complex types.
This commit is contained in:
parent
fd9caa1bc2
commit
0decc31aa8
@ -44,16 +44,29 @@ template<bool Conjugate> struct conj_if;
|
|||||||
|
|
||||||
template<> struct conj_if<true> {
|
template<> struct conj_if<true> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T operator()(const T& x) { return numext::conj(x); }
|
inline T operator()(const T& x) const { return numext::conj(x); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T pconj(const T& x) { return internal::pconj(x); }
|
inline T pconj(const T& x) const { return internal::pconj(x); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct conj_if<false> {
|
template<> struct conj_if<false> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T& operator()(const T& x) { return x; }
|
inline const T& operator()(const T& x) const { return x; }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T& pconj(const T& x) { return x; }
|
inline const T& pconj(const T& x) const { return x; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Generic implementation for custom complex types.
|
||||||
|
template<typename LhsScalar, typename RhsScalar, bool ConjLhs, bool ConjRhs>
|
||||||
|
struct conj_helper
|
||||||
|
{
|
||||||
|
typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar>::ReturnType Scalar;
|
||||||
|
|
||||||
|
EIGEN_STRONG_INLINE Scalar pmadd(const LhsScalar& x, const RhsScalar& y, const Scalar& c) const
|
||||||
|
{ return padd(c, pmul(x,y)); }
|
||||||
|
|
||||||
|
EIGEN_STRONG_INLINE Scalar pmul(const LhsScalar& x, const RhsScalar& y) const
|
||||||
|
{ return conj_if<ConjLhs>()(x) * conj_if<ConjRhs>()(y); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Scalar> struct conj_helper<Scalar,Scalar,false,false>
|
template<typename Scalar> struct conj_helper<Scalar,Scalar,false,false>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user