GlobalFunctions.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) 2010-2016 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
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_GLOBAL_FUNCTIONS_H
12 #define EIGEN_GLOBAL_FUNCTIONS_H
13 
14 #ifdef EIGEN_PARSED_BY_DOXYGEN
15 
16 #define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR,DOC_OP,DOC_DETAILS) \
17  \
23  template<typename Derived> \
24  inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \
25  NAME(const Eigen::ArrayBase<Derived>& x);
26 
27 #else
28 
29 #define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR,DOC_OP,DOC_DETAILS) \
30  template<typename Derived> \
31  inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \
32  (NAME)(const Eigen::ArrayBase<Derived>& x) { \
33  return Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived>(x.derived()); \
34  }
35 
36 #endif // EIGEN_PARSED_BY_DOXYGEN
37 
38 #define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \
39  \
40  template<typename Derived> \
41  struct NAME##_retval<ArrayBase<Derived> > \
42  { \
43  typedef const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> type; \
44  }; \
45  template<typename Derived> \
46  struct NAME##_impl<ArrayBase<Derived> > \
47  { \
48  static inline typename NAME##_retval<ArrayBase<Derived> >::type run(const Eigen::ArrayBase<Derived>& x) \
49  { \
50  return typename NAME##_retval<ArrayBase<Derived> >::type(x.derived()); \
51  } \
52  };
53 
54 namespace Eigen
55 {
57  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op,imaginary part,\sa ArrayBase::imag)
61  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op,cosine,\sa ArrayBase::cos)
62  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op,tangent,\sa ArrayBase::tan)
63  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan,scalar_atan_op,arc-tangent,\sa ArrayBase::atan)
64  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op,arc-sine,\sa ArrayBase::asin)
65  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op,arc-consine,\sa ArrayBase::acos)
66  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sinh,scalar_sinh_op,hyperbolic sine,\sa ArrayBase::sinh)
67  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cosh,scalar_cosh_op,hyperbolic cosine,\sa ArrayBase::cosh)
68  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tanh,scalar_tanh_op,hyperbolic tangent,\sa ArrayBase::tanh)
69 #if EIGEN_HAS_CXX11_MATH
70  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asinh,scalar_asinh_op,inverse hyperbolic sine,\sa ArrayBase::asinh)
71  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acosh,scalar_acosh_op,inverse hyperbolic cosine,\sa ArrayBase::acosh)
72  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atanh,scalar_atanh_op,inverse hyperbolic tangent,\sa ArrayBase::atanh)
73 #endif
75  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(lgamma,scalar_lgamma_op,natural logarithm of the gamma function,\sa ArrayBase::lgamma)
76  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(digamma,scalar_digamma_op,derivative of lgamma,\sa ArrayBase::digamma)
77  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erf,scalar_erf_op,error function,\sa ArrayBase::erf)
78  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erfc,scalar_erfc_op,complement error function,\sa ArrayBase::erfc)
79  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ndtri,scalar_ndtri_op,inverse normal distribution function,\sa ArrayBase::ndtri)
80  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op,exponential,\sa ArrayBase::exp)
81  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(expm1,scalar_expm1_op,exponential of a value minus 1,\sa ArrayBase::expm1)
82  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op,natural logarithm,\sa Eigen::log10 DOXCOMMA ArrayBase::log)
83  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log1p,scalar_log1p_op,natural logarithm of 1 plus the value,\sa ArrayBase::log1p)
84  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log10,scalar_log10_op,base 10 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log10)
85  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log2,scalar_log2_op,base 2 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log2)
86  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op,absolute value,\sa ArrayBase::abs DOXCOMMA MatrixBase::cwiseAbs)
87  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs2,scalar_abs2_op,squared absolute value,\sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2)
90  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rsqrt,scalar_rsqrt_op,reciprocal square root,\sa ArrayBase::rsqrt)
91  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(square,scalar_square_op,square (power 2),\sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square)
92  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cube,scalar_cube_op,cube (power 3),\sa Eigen::pow DOXCOMMA ArrayBase::cube)
93  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rint,scalar_rint_op,nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
94  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(round,scalar_round_op,nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
95  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(floor,scalar_floor_op,nearest integer not greater than the giben value,\sa Eigen::ceil DOXCOMMA ArrayBase::floor)
96  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ceil,scalar_ceil_op,nearest integer not less than the giben value,\sa Eigen::floor DOXCOMMA ArrayBase::ceil)
97  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isnan,scalar_isnan_op,not-a-number test,\sa Eigen::isinf DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isnan)
98  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isinf,scalar_isinf_op,infinite value test,\sa Eigen::isnan DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isinf)
99  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isfinite,scalar_isfinite_op,finite value test,\sa Eigen::isinf DOXCOMMA Eigen::isnan DOXCOMMA ArrayBase::isfinite)
100  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sign,scalar_sign_op,sign (or 0),\sa ArrayBase::sign)
101 
102 
110 #ifdef EIGEN_PARSED_BY_DOXYGEN
111  template<typename Derived,typename ScalarExponent>
112  inline const CwiseBinaryOp<internal::scalar_pow_op<Derived::Scalar,ScalarExponent>,Derived,Constant<ScalarExponent> >
113  pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent);
114 #else
115  template <typename Derived,typename ScalarExponent>
116  EIGEN_DEVICE_FUNC inline
119  EIGEN_COMMA ScalarExponent EIGEN_COMMA
120  EIGEN_SCALAR_BINARY_SUPPORTED(pow,typename Derived::Scalar,ScalarExponent)>::type,pow))
121  pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent)
122  {
123  typedef typename internal::promote_scalar_arg<typename Derived::Scalar,ScalarExponent,
124  EIGEN_SCALAR_BINARY_SUPPORTED(pow,typename Derived::Scalar,ScalarExponent)>::type PromotedExponent;
125  return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedExponent,pow)(x.derived(),
127  }
128 #endif
129 
141  template<typename Derived,typename ExponentDerived>
144  {
146  x.derived(),
147  exponents.derived()
148  );
149  }
150 
164 #ifdef EIGEN_PARSED_BY_DOXYGEN
165  template<typename Scalar,typename Derived>
166  inline const CwiseBinaryOp<internal::scalar_pow_op<Scalar,Derived::Scalar>,Constant<Scalar>,Derived>
167  pow(const Scalar& x,const Eigen::ArrayBase<Derived>& x);
168 #else
169  template <typename Scalar, typename Derived>
170  EIGEN_DEVICE_FUNC inline
171  EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(
174  EIGEN_SCALAR_BINARY_SUPPORTED(pow,Scalar,typename Derived::Scalar)>::type,Derived,pow))
175  pow(const Scalar& x, const Eigen::ArrayBase<Derived>& exponents) {
176  typedef typename internal::promote_scalar_arg<typename Derived::Scalar,Scalar,
177  EIGEN_SCALAR_BINARY_SUPPORTED(pow,Scalar,typename Derived::Scalar)>::type PromotedScalar;
178  return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedScalar,Derived,pow)(
179  typename internal::plain_constant_type<Derived,PromotedScalar>::type(exponents.derived().rows(), exponents.derived().cols(), internal::scalar_constant_op<PromotedScalar>(x)), exponents.derived());
180  }
181 #endif
182 
183 
184  namespace internal
185  {
189  }
190 }
191 
192 // TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...)
193 
194 #endif // EIGEN_GLOBAL_FUNCTIONS_H
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
Definition: ArrayBase.h:354
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbs2ReturnType cwiseAbs2() const
Definition: MatrixBase.h:47
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
SCALAR Scalar
Definition: bench_gemm.cpp:46
#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR, SCALAR, OPNAME)
Definition: Macros.h:1347
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Jet< T, N > cos(const Jet< T, N > &f)
Definition: jet.h:426
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
#define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME, FUNCTOR)
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t idx_t idx_t * part
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
Definition: ArrayBase.h:143
EIGEN_DEVICE_FUNC const Expm1ReturnType expm1() const
Definition: ArrayBase.h:112
EIGEN_DEVICE_FUNC const LogisticReturnType logistic() const
Definition: ArrayBase.h:398
EIGEN_DEVICE_FUNC const NdtriReturnType ndtri() const
EIGEN_DEVICE_FUNC const RoundReturnType round() const
Definition: ArrayBase.h:468
#define EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(SCALAR, EXPR, OPNAME)
Definition: Macros.h:1351
EIGEN_DEVICE_FUNC const ErfReturnType erf() const
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
Definition: ArrayBase.h:326
Definition: test.py:1
EIGEN_DEVICE_FUNC const CubeReturnType cube() const
Definition: ArrayBase.h:440
Jet< T, N > acos(const Jet< T, N > &f)
Definition: jet.h:432
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
Jet< T, N > sin(const Jet< T, N > &f)
Definition: jet.h:439
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
Definition: DenseBase.h:110
EIGEN_DEVICE_FUNC const TanReturnType tan() const
Definition: ArrayBase.h:270
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar, typename ExponentDerived::Scalar >, const Derived, const ExponentDerived > pow(const Eigen::ArrayBase< Derived > &x, const Eigen::ArrayBase< ExponentDerived > &exponents)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
Definition: ArrayBase.h:256
#define isfinite(X)
Definition: main.h:95
#define isinf(X)
Definition: main.h:94
EIGEN_DEVICE_FUNC const DigammaReturnType digamma() const
Definition: ArrayBase.h:638
Definition: cast.h:1238
EIGEN_DEVICE_FUNC const LogReturnType log() const
Definition: ArrayBase.h:129
EIGEN_DEVICE_FUNC const ErfcReturnType erfc() const
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
EIGEN_DEVICE_FUNC const LogReturnType log() const
EIGEN_DEVICE_FUNC RealReturnType real() const
Definition: DenseBase.h:101
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
#define EIGEN_COMMA
Definition: Macros.h:904
EIGEN_DEVICE_FUNC const CubeReturnType cube() const
EIGEN_DEVICE_FUNC const LgammaReturnType lgamma() const
EIGEN_DEVICE_FUNC const CwiseSqrtReturnType cwiseSqrt() const
Definition: MatrixBase.h:60
EIGEN_DEVICE_FUNC const Log10ReturnType log10() const
Definition: ArrayBase.h:159
Definition: main.h:101
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
Definition: ArrayBase.h:412
EIGEN_DEVICE_FUNC const AtanReturnType atan() const
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition: ArrayBase.h:67
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
EIGEN_DEVICE_FUNC const SquareReturnType square() const
EIGEN_DEVICE_FUNC const Expm1ReturnType expm1() const
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME, FUNCTOR, DOC_OP, DOC_DETAILS)
CwiseNullaryOp< scalar_constant_op< Scalar >, const typename conditional< is_same< typename traits< Expr >::XprKind, MatrixXpr >::value, matrix_type, array_type >::type > type
Definition: XprHelper.h:655
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log2(const bfloat16 &a)
Definition: BFloat16.h:508
EIGEN_DEVICE_FUNC const RintReturnType rint() const
EIGEN_DEVICE_FUNC const DigammaReturnType digamma() const
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
Definition: ArrayBase.h:496
EIGEN_DEVICE_FUNC const AcosReturnType acos() const
Definition: ArrayBase.h:298
EIGEN_DEVICE_FUNC const SquareReturnType square() const
Definition: ArrayBase.h:426
#define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME, TYPEA, TYPEB)
Definition: Macros.h:1344
EIGEN_DEVICE_FUNC const SignReturnType sign() const
Definition: main.h:100
EIGEN_DEVICE_FUNC const RsqrtReturnType rsqrt() const
Definition: ArrayBase.h:204
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Definition: ArrayBase.h:188
Unit3_ normal(const OrientedPlane3_ &p)
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
Definition: ArrayBase.h:340
EIGEN_DEVICE_FUNC const LgammaReturnType lgamma() const
Definition: ArrayBase.h:621
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
EIGEN_DEVICE_FUNC const AsinReturnType asin() const
Definition: ArrayBase.h:312
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate() const
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
Definition: ArrayBase.h:482
EIGEN_DEVICE_FUNC const RsqrtReturnType rsqrt() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseAbsReturnType cwiseAbs() const
Definition: MatrixBase.h:34
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
Definition: ArrayBase.h:81
EIGEN_DEVICE_FUNC const Eigen::ArrayBase< Derived > & exponents
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate() const
Definition: DenseBase.h:75
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
EIGEN_DEVICE_FUNC const ErfReturnType erf() const
Definition: ArrayBase.h:656
#define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X)
EIGEN_DEVICE_FUNC const AtanReturnType atan() const
Definition: ArrayBase.h:284
EIGEN_DEVICE_FUNC const Log10ReturnType log10() const
EIGEN_DEVICE_FUNC const TanReturnType tan() const
EIGEN_DEVICE_FUNC const SignReturnType sign() const
Definition: ArrayBase.h:220
static double error
Definition: testRot3.cpp:37
int integer
Definition: datatypes.h:8
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
Definition: ArrayBase.h:53
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
EIGEN_DEVICE_FUNC const ErfcReturnType erfc() const
Definition: ArrayBase.h:674
EIGEN_DEVICE_FUNC const NdtriReturnType ndtri() const
Definition: ArrayBase.h:694
Annotation indicating that a class derives from another given type.
Definition: attr.h:61
EIGEN_DEVICE_FUNC const CosReturnType cos() const
Definition: ArrayBase.h:238
Jet< T, N > pow(const Jet< T, N > &f, double g)
Definition: jet.h:570
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
Definition: ArrayBase.h:98
EIGEN_DEVICE_FUNC const LogisticReturnType logistic() const
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
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
#define abs(x)
Definition: datatypes.h:17
EIGEN_DEVICE_FUNC const AsinReturnType asin() const
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
EIGEN_DEVICE_FUNC const Log2ReturnType log2() const
Definition: ArrayBase.h:171
#define isnan(X)
Definition: main.h:93
Definition: pytypes.h:1370
EIGEN_DEVICE_FUNC const CwiseArgReturnType cwiseArg() const
Definition: MatrixBase.h:96
EIGEN_DEVICE_FUNC const RoundReturnType round() const


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