ConjHelper.h
Go to the documentation of this file.
1 
2 // This file is part of Eigen, a lightweight C++ template library
3 // for linear algebra.
4 //
5 // Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_ARCH_CONJ_HELPER_H
12 #define EIGEN_ARCH_CONJ_HELPER_H
13 
14 #define EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(PACKET_CPLX, PACKET_REAL) \
15  template <> \
16  struct conj_helper<PACKET_REAL, PACKET_CPLX, false, false> { \
17  EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_REAL& x, \
18  const PACKET_CPLX& y, \
19  const PACKET_CPLX& c) const { \
20  return padd(c, this->pmul(x, y)); \
21  } \
22  EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_REAL& x, \
23  const PACKET_CPLX& y) const { \
24  return PACKET_CPLX(Eigen::internal::pmul<PACKET_REAL>(x, y.v)); \
25  } \
26  }; \
27  \
28  template <> \
29  struct conj_helper<PACKET_CPLX, PACKET_REAL, false, false> { \
30  EIGEN_STRONG_INLINE PACKET_CPLX pmadd(const PACKET_CPLX& x, \
31  const PACKET_REAL& y, \
32  const PACKET_CPLX& c) const { \
33  return padd(c, this->pmul(x, y)); \
34  } \
35  EIGEN_STRONG_INLINE PACKET_CPLX pmul(const PACKET_CPLX& x, \
36  const PACKET_REAL& y) const { \
37  return PACKET_CPLX(Eigen::internal::pmul<PACKET_REAL>(x.v, y)); \
38  } \
39  };
40 
41 namespace Eigen {
42 namespace internal {
43 
44 template<bool Conjugate> struct conj_if;
45 
46 template<> struct conj_if<true> {
47  template<typename T>
49  template<typename T>
51 };
52 
53 template<> struct conj_if<false> {
54  template<typename T>
55  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& operator()(const T& x) const { return x; }
56  template<typename T>
57  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T& pconj(const T& x) const { return x; }
58 };
59 
60 // Generic Implementation, assume scalars since the packet-version is
61 // specialized below.
62 template<typename LhsType, typename RhsType, bool ConjLhs, bool ConjRhs>
63 struct conj_helper {
65 
67  pmadd(const LhsType& x, const RhsType& y, const ResultType& c) const
68  { return this->pmul(x, y) + c; }
69 
71  pmul(const LhsType& x, const RhsType& y) const
72  { return conj_if<ConjLhs>()(x) * conj_if<ConjRhs>()(y); }
73 };
74 
75 template<typename LhsScalar, typename RhsScalar>
76 struct conj_helper<LhsScalar, RhsScalar, true, true> {
78 
80  pmadd(const LhsScalar& x, const RhsScalar& y, const ResultType& c) const
81  { return this->pmul(x, y) + c; }
82 
83  // We save a conjuation by using the identity conj(a)*conj(b) = conj(a*b).
85  pmul(const LhsScalar& x, const RhsScalar& y) const
86  { return numext::conj(x * y); }
87 };
88 
89 // Implementation with equal type, use packet operations.
90 template<typename Packet, bool ConjLhs, bool ConjRhs>
91 struct conj_helper<Packet, Packet, ConjLhs, ConjRhs>
92 {
93  typedef Packet ResultType;
96 
97 
100 };
101 
102 template<typename Packet>
103 struct conj_helper<Packet, Packet, true, true>
104 {
106 
108  { return Eigen::internal::pmadd(pconj(x), pconj(y), c); }
109  // We save a conjuation by using the identity conj(a)*conj(b) = conj(a*b).
111  { return pconj(Eigen::internal::pmul(x, y)); }
112 };
113 
114 } // namespace internal
115 } // namespace Eigen
116 
117 #endif // EIGEN_ARCH_CONJ_HELPER_H
Eigen::internal::conj_if< false >::pconj
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE T & pconj(const T &x) const
Definition: ConjHelper.h:57
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
Eigen::internal::conj_helper< LhsScalar, RhsScalar, true, true >::pmul
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType pmul(const LhsScalar &x, const RhsScalar &y) const
Definition: ConjHelper.h:85
Eigen::ScalarBinaryOpTraits
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:801
Eigen::internal::pconj
EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf &a)
Definition: AltiVec/Complex.h:167
Eigen::internal::conj_helper::pmul
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType pmul(const LhsType &x, const RhsType &y) const
Definition: ConjHelper.h:71
Eigen::internal::conj_helper< Packet, Packet, ConjLhs, ConjRhs >::pmadd
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pmadd(const Packet &x, const Packet &y, const Packet &c) const
Definition: ConjHelper.h:94
Eigen::internal::conj_helper< Packet, Packet, true, true >::ResultType
Packet ResultType
Definition: ConjHelper.h:105
EIGEN_STRONG_INLINE
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
Eigen::internal::conj_if
Definition: ConjHelper.h:44
Eigen::internal::Packet
Definition: ZVector/PacketMath.h:47
Eigen::Triplet< double >
conj
AnnoyingScalar conj(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:104
Eigen::internal::conj_helper::ResultType
ScalarBinaryOpTraits< LhsType, RhsType >::ReturnType ResultType
Definition: ConjHelper.h:64
Eigen::internal::conj_helper< Packet, Packet, ConjLhs, ConjRhs >::ResultType
Packet ResultType
Definition: ConjHelper.h:93
Eigen::internal::conj_helper< Packet, Packet, true, true >::pmadd
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pmadd(const Packet &x, const Packet &y, const Packet &c) const
Definition: ConjHelper.h:107
Eigen::internal::conj_helper< Packet, Packet, true, true >::pmul
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pmul(const Packet &x, const Packet &y) const
Definition: ConjHelper.h:110
Eigen::internal::pmul
EIGEN_DEVICE_FUNC Packet pmul(const Packet &a, const Packet &b)
Definition: GenericPacketMath.h:237
Eigen::internal::conj_helper< LhsScalar, RhsScalar, true, true >::pmadd
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType pmadd(const LhsScalar &x, const RhsScalar &y, const ResultType &c) const
Definition: ConjHelper.h:80
Eigen::internal::conj_helper
Definition: ConjHelper.h:63
Eigen::internal::y
const Scalar & y
Definition: Eigen/src/Core/MathFunctions.h:821
Eigen::internal::conj_if< true >::pconj
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T pconj(const T &x) const
Definition: ConjHelper.h:50
Eigen::internal::pmadd
EIGEN_STRONG_INLINE Packet4f pmadd(const Packet4f &a, const Packet4f &b, const Packet4f &c)
Definition: AltiVec/PacketMath.h:827
Eigen::internal::conj_helper::pmadd
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType pmadd(const LhsType &x, const RhsType &y, const ResultType &c) const
Definition: ConjHelper.h:67
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::conj_if< true >::operator()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(const T &x) const
Definition: ConjHelper.h:48
Eigen::internal::conj_if< false >::operator()
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE T & operator()(const T &x) const
Definition: ConjHelper.h:55
Eigen::internal::conj_helper< LhsScalar, RhsScalar, true, true >::ResultType
ScalarBinaryOpTraits< LhsScalar, RhsScalar >::ReturnType ResultType
Definition: ConjHelper.h:77
Eigen::internal::conj_helper< Packet, Packet, ConjLhs, ConjRhs >::pmul
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pmul(const Packet &x, const Packet &y) const
Definition: ConjHelper.h:98


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:10