SpecialFunctionsFunctors.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2016 Eugene Brevdo <ebrevdo@gmail.com>
5 // Copyright (C) 2016 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_SPECIALFUNCTIONS_FUNCTORS_H
12 #define EIGEN_SPECIALFUNCTIONS_FUNCTORS_H
13 
14 namespace Eigen {
15 
16 namespace internal {
17 
18 
24 template<typename Scalar> struct scalar_igamma_op : binary_op_base<Scalar,Scalar>
25 {
26  EIGEN_EMPTY_STRUCT_CTOR(scalar_igamma_op)
27  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& x) const {
28  using numext::igamma; return igamma(a, x);
29  }
30  template<typename Packet>
32  return internal::pigamma(a, x);
33  }
34 };
35 template<typename Scalar>
37  enum {
38  // Guesstimate
41  };
42 };
43 
50 template <typename Scalar>
53  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(const Scalar& a, const Scalar& x) const {
55  return igamma_der_a(a, x);
56  }
57  template <typename Packet>
59  return internal::pigamma_der_a(a, x);
60  }
61 };
62 template <typename Scalar>
64  enum {
65  // 2x the cost of igamma
68  };
69 };
70 
78 template <typename Scalar>
81  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(const Scalar& alpha, const Scalar& sample) const {
83  return gamma_sample_der_alpha(alpha, sample);
84  }
85  template <typename Packet>
87  return internal::pgamma_sample_der_alpha(alpha, sample);
88  }
89 };
90 template <typename Scalar>
92  enum {
93  // 2x the cost of igamma, minus the lgamma cost (the lgamma cancels out)
96  };
97 };
98 
104 template<typename Scalar> struct scalar_igammac_op : binary_op_base<Scalar,Scalar>
105 {
107  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a, const Scalar& x) const {
108  using numext::igammac; return igammac(a, x);
109  }
110  template<typename Packet>
112  {
113  return internal::pigammac(a, x);
114  }
115 };
116 template<typename Scalar>
118  enum {
119  // Guesstimate
122  };
123 };
124 
125 
130 template<typename Scalar> struct scalar_betainc_op {
132  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& x, const Scalar& a, const Scalar& b) const {
133  using numext::betainc; return betainc(x, a, b);
134  }
135  template<typename Packet>
137  {
138  return internal::pbetainc(x, a, b);
139  }
140 };
141 template<typename Scalar>
143  enum {
144  // Guesstimate
147  };
148 };
149 
150 
156 template<typename Scalar> struct scalar_lgamma_op {
158  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const {
159  using numext::lgamma; return lgamma(a);
160  }
163 };
164 template<typename Scalar>
166 {
167  enum {
168  // Guesstimate
171  };
172 };
173 
178 template<typename Scalar> struct scalar_digamma_op {
180  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const {
181  using numext::digamma; return digamma(a);
182  }
185 };
186 template<typename Scalar>
188 {
189  enum {
190  // Guesstimate
193  };
194 };
195 
200 template<typename Scalar> struct scalar_zeta_op {
202  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& x, const Scalar& q) const {
203  using numext::zeta; return zeta(x, q);
204  }
207 };
208 template<typename Scalar>
210 {
211  enum {
212  // Guesstimate
215  };
216 };
217 
222 template<typename Scalar> struct scalar_polygamma_op {
224  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& n, const Scalar& x) const {
225  using numext::polygamma; return polygamma(n, x);
226  }
229 };
230 template<typename Scalar>
232 {
233  enum {
234  // Guesstimate
237  };
238 };
239 
244 template<typename Scalar> struct scalar_erf_op {
247  operator()(const Scalar& a) const {
248  return numext::erf(a);
249  }
250  template <typename Packet>
252  return perf(x);
253  }
254 };
255 template <typename Scalar>
257  enum {
259  Cost =
260  (PacketAccess
261 #ifdef EIGEN_VECTORIZE_FMA
262  // TODO(rmlarsen): Move the FMA cost model to a central location.
263  // Haswell can issue 2 add/mul/madd per cycle.
264  // 10 pmadd, 2 pmul, 1 div, 2 other
268 #else
272 #endif
273  // Assume for simplicity that this is as expensive as an exp().
275  };
276 };
277 
283 template<typename Scalar> struct scalar_erfc_op {
285  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const {
286  using numext::erfc; return erfc(a);
287  }
289  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a) const { return internal::perfc(a); }
290 };
291 template<typename Scalar>
293 {
294  enum {
295  // Guesstimate
298  };
299 };
300 
306 template<typename Scalar> struct scalar_ndtri_op {
308  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (const Scalar& a) const {
309  using numext::ndtri; return ndtri(a);
310  }
313 };
314 template<typename Scalar>
316 {
317  enum {
318  // On average, We are evaluating rational functions with degree N=9 in the
319  // numerator and denominator. This results in 2*N additions and 2*N
320  // multiplications.
323  };
324 };
325 
326 } // end namespace internal
327 
328 } // end namespace Eigen
329 
330 #endif // EIGEN_SPECIALFUNCTIONS_FUNCTORS_H
SCALAR Scalar
Definition: bench_gemm.cpp:46
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet &alpha, const Packet &sample) const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pndtri(const Packet &a)
#define EIGEN_STRONG_INLINE
Definition: Macros.h:917
#define EIGEN_EMPTY_STRUCT_CTOR(X)
Definition: XprHelper.h:22
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &a) const
Scalar * b
Definition: benchVecAdd.cpp:17
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igamma_der_a_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igamma_der_a(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet &a, const Packet &x) const
EIGEN_DEVICE_FUNC const NdtriReturnType ndtri() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet perf(const Packet &a)
EIGEN_DEVICE_FUNC const ErfReturnType erf() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &a) const
packet_traits< Scalar >::type Packet
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet &a, const Packet &x) const
int n
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_gamma_sample_der_alpha_op< typename AlphaDerived::Scalar >, const AlphaDerived, const SampleDerived > gamma_sample_der_alpha(const Eigen::ArrayBase< AlphaDerived > &alpha, const Eigen::ArrayBase< SampleDerived > &sample)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pdigamma(const Packet &a)
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
packet_traits< Scalar >::type Packet
EIGEN_DEVICE_FUNC const ErfcReturnType erfc() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &a) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet &a, const Packet &x) const
EIGEN_DEVICE_FUNC const LgammaReturnType lgamma() const
const CwiseBinaryOp< internal::scalar_zeta_op< Scalar >, const Derived, const DerivedQ > zeta(const EIGEN_CURRENT_STORAGE_BASE_CLASS< DerivedQ > &q) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &x, const Packet &q) const
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pbetainc(const Packet &a, const Packet &b, const Packet &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &n, const Packet &x) const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plgamma(const Packet &a)
EIGEN_DEVICE_FUNC const DigammaReturnType digamma() const
packet_traits< Scalar >::type Packet
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pigammac(const Packet &a, const Packet &x)
RealScalar alpha
EIGEN_DEVICE_FUNC const Scalar & q
packet_traits< Scalar >::type Packet
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet perfc(const Packet &a)
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &a) const
packet_traits< Scalar >::type Packet
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()(const Scalar &a) const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ppolygamma(const Packet &n, const Packet &x)
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igamma_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igamma(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pigamma(const Packet &a, const Packet &x)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pzeta(const Packet &x, const Packet &q)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(const Packet &x, const Packet &a, const Packet &b) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorCwiseTernaryOp< internal::scalar_betainc_op< typename XDerived::Scalar >, const ADerived, const BDerived, const XDerived > betainc(const ADerived &a, const BDerived &b, const XDerived &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
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_igammac_op< typename Derived::Scalar >, const Derived, const ExponentDerived > igammac(const Eigen::ArrayBase< Derived > &a, const Eigen::ArrayBase< ExponentDerived > &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pgamma_sample_der_alpha(const Packet &alpha, const Packet &sample)
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_polygamma_op< typename DerivedX::Scalar >, const DerivedN, const DerivedX > polygamma(const Eigen::ArrayBase< DerivedN > &n, const Eigen::ArrayBase< DerivedX > &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet pigamma_der_a(const Packet &a, const Packet &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &x) const


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:36:18