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  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(lgamma,scalar_lgamma_op,natural logarithm of the gamma function,\sa ArrayBase::lgamma)
70  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(digamma,scalar_digamma_op,derivative of lgamma,\sa ArrayBase::digamma)
71  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erf,scalar_erf_op,error function,\sa ArrayBase::erf)
72  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erfc,scalar_erfc_op,complement error function,\sa ArrayBase::erfc)
73  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op,exponential,\sa ArrayBase::exp)
74  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op,natural logarithm,\sa Eigen::log10 DOXCOMMA ArrayBase::log)
75  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log1p,scalar_log1p_op,natural logarithm of 1 plus the value,\sa ArrayBase::log1p)
76  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log10,scalar_log10_op,base 10 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log)
77  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op,absolute value,\sa ArrayBase::abs DOXCOMMA MatrixBase::cwiseAbs)
78  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs2,scalar_abs2_op,squared absolute value,\sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2)
81  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rsqrt,scalar_rsqrt_op,reciprocal square root,\sa ArrayBase::rsqrt)
82  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(square,scalar_square_op,square (power 2),\sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square)
83  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cube,scalar_cube_op,cube (power 3),\sa Eigen::pow DOXCOMMA ArrayBase::cube)
84  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(round,scalar_round_op,nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
85  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(floor,scalar_floor_op,nearest integer not greater than the giben value,\sa Eigen::ceil DOXCOMMA ArrayBase::floor)
86  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ceil,scalar_ceil_op,nearest integer not less than the giben value,\sa Eigen::floor DOXCOMMA ArrayBase::ceil)
87  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isnan,scalar_isnan_op,not-a-number test,\sa Eigen::isinf DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isnan)
88  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isinf,scalar_isinf_op,infinite value test,\sa Eigen::isnan DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isinf)
89  EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isfinite,scalar_isfinite_op,finite value test,\sa Eigen::isinf DOXCOMMA Eigen::isnan DOXCOMMA ArrayBase::isfinite)
91 
92 
100 #ifdef EIGEN_PARSED_BY_DOXYGEN
101  template<typename Derived,typename ScalarExponent>
102  inline const CwiseBinaryOp<internal::scalar_pow_op<Derived::Scalar,ScalarExponent>,Derived,Constant<ScalarExponent> >
103  pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent);
104 #else
105  template<typename Derived,typename ScalarExponent>
106  inline typename internal::enable_if< !(internal::is_same<typename Derived::Scalar,ScalarExponent>::value) && EIGEN_SCALAR_BINARY_SUPPORTED(pow,typename Derived::Scalar,ScalarExponent),
107  const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,ScalarExponent,pow) >::type
108  pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent) {
109  return x.derived().pow(exponent);
110  }
111 
112  template<typename Derived>
114  pow(const Eigen::ArrayBase<Derived>& x, const typename Derived::Scalar& exponent) {
115  return x.derived().pow(exponent);
116  }
117 #endif
118 
130  template<typename Derived,typename ExponentDerived>
133  {
135  x.derived(),
136  exponents.derived()
137  );
138  }
139 
153 #ifdef EIGEN_PARSED_BY_DOXYGEN
154  template<typename Scalar,typename Derived>
155  inline const CwiseBinaryOp<internal::scalar_pow_op<Scalar,Derived::Scalar>,Constant<Scalar>,Derived>
156  pow(const Scalar& x,const Eigen::ArrayBase<Derived>& x);
157 #else
158  template<typename Scalar, typename Derived>
160  const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,Derived,pow) >::type
161  pow(const Scalar& x, const Eigen::ArrayBase<Derived>& exponents)
162  {
164  typename internal::plain_constant_type<Derived,Scalar>::type(exponents.rows(), exponents.cols(), x), exponents.derived() );
165  }
166 
167  template<typename Derived>
169  pow(const typename Derived::Scalar& x, const Eigen::ArrayBase<Derived>& exponents)
170  {
172  typename internal::plain_constant_type<Derived,typename Derived::Scalar>::type(exponents.rows(), exponents.cols(), x), exponents.derived() );
173  }
174 #endif
175 
176 
177  namespace internal
178  {
182  }
183 }
184 
185 // TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...)
186 
187 #endif // EIGEN_GLOBAL_FUNCTIONS_H
Eigen::conj
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:543
sqrt
const EIGEN_DEVICE_FUNC SqrtReturnType sqrt() const
Definition: ArrayCwiseUnaryOps.h:152
sin
const EIGEN_DEVICE_FUNC SinReturnType sin() const
Definition: ArrayCwiseUnaryOps.h:220
Eigen
Definition: common.h:73
Eigen::half_impl::isfinite
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isfinite(const half &a)
Definition: Half.h:441
inverse
const EIGEN_DEVICE_FUNC InverseReturnType inverse() const
Definition: ArrayCwiseUnaryOps.h:332
erf
const EIGEN_DEVICE_FUNC ErfReturnType erf() const
Definition: ArrayCwiseUnaryOps.h:528
Eigen::CwiseBinaryOp
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
atan
const EIGEN_DEVICE_FUNC AtanReturnType atan() const
Definition: ArrayCwiseUnaryOps.h:248
Eigen::half_impl::pow
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half &a, const half &b)
Definition: Half.h:477
erfc
const EIGEN_DEVICE_FUNC ErfcReturnType erfc() const
Definition: ArrayCwiseUnaryOps.h:549
sign
const EIGEN_DEVICE_FUNC SignReturnType sign() const
Definition: ArrayCwiseUnaryOps.h:184
real
float real
Definition: datatypes.h:10
Eigen::half_impl::isinf
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isinf(const half &a)
Definition: Half.h:431
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:105
abs2
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Abs2ReturnType abs2() const
Definition: ArrayCwiseUnaryOps.h:71
Scalar
SCALAR Scalar
Definition: common.h:84
asin
const EIGEN_DEVICE_FUNC AsinReturnType asin() const
Definition: ArrayCwiseUnaryOps.h:276
exp
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
Definition: ArrayCwiseUnaryOps.h:88
Eigen::ArrayBase::pow
internal::enable_if< !(internal::is_same< typename Derived::Scalar, Scalar >::value) &&EIGEN_SCALAR_BINARY_SUPPORTED(pow, Scalar, typename Derived::Scalar), const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar, Derived, pow) >::type pow(const Scalar &x, const Eigen::ArrayBase< Derived > &exponents)
Definition: GlobalFunctions.h:161
log1p
const EIGEN_DEVICE_FUNC Log1pReturnType log1p() const
Definition: ArrayCwiseUnaryOps.h:119
cosh
const EIGEN_DEVICE_FUNC CoshReturnType cosh() const
Definition: ArrayCwiseUnaryOps.h:318
digamma
const EIGEN_DEVICE_FUNC DigammaReturnType digamma() const
Definition: ArrayCwiseUnaryOps.h:507
abs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE AbsReturnType abs() const
Definition: ArrayCwiseUnaryOps.h:43
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY
#define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME, FUNCTOR)
Definition: GlobalFunctions.h:38
lgamma
const EIGEN_DEVICE_FUNC LgammaReturnType lgamma() const
Definition: ArrayCwiseUnaryOps.h:490
square
const EIGEN_DEVICE_FUNC SquareReturnType square() const
Definition: ArrayCwiseUnaryOps.h:346
x
Scalar * x
Definition: level1_cplx_impl.h:89
Eigen::ArrayBase::pow
internal::enable_if< !(internal::is_same< typename Derived::Scalar, ScalarExponent >::value) &&EIGEN_SCALAR_BINARY_SUPPORTED(pow, typename Derived::Scalar, ScalarExponent), const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived, ScalarExponent, pow) >::type pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
Definition: GlobalFunctions.h:108
imag
const EIGEN_DEVICE_FUNC ImagReturnType imag() const
Definition: CommonCwiseUnaryOps.h:95
Eigen::ArrayBase< ArrayWrapper< ExpressionType > >::Scalar
internal::traits< ArrayWrapper< ExpressionType > >::Scalar Scalar
Definition: ArrayBase.h:50
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:57
tan
const EIGEN_DEVICE_FUNC TanReturnType tan() const
Definition: ArrayCwiseUnaryOps.h:234
rsqrt
const EIGEN_DEVICE_FUNC RsqrtReturnType rsqrt() const
Definition: ArrayCwiseUnaryOps.h:168
acos
const EIGEN_DEVICE_FUNC AcosReturnType acos() const
Definition: ArrayCwiseUnaryOps.h:262
cube
const EIGEN_DEVICE_FUNC CubeReturnType cube() const
Definition: ArrayCwiseUnaryOps.h:360
cwiseAbs2
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE CwiseAbs2ReturnType cwiseAbs2() const
Definition: MatrixCwiseUnaryOps.h:45
Eigen::ArrayBase
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
conjugate
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate() const
Definition: CommonCwiseUnaryOps.h:74
Eigen::ArrayBase::pow
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)
Definition: GlobalFunctions.h:132
integer
int integer
Definition: datatypes.h:8
tanh
const EIGEN_DEVICE_FUNC TanhReturnType tanh() const
Definition: ArrayCwiseUnaryOps.h:290
Eigen::imag
DerType::Scalar imag(const AutoDiffScalar< DerType > &)
Definition: AutoDiffScalar.h:547
cwiseSqrt
const EIGEN_DEVICE_FUNC CwiseSqrtReturnType cwiseSqrt() const
Definition: MatrixCwiseUnaryOps.h:58
a
Scalar * a
Definition: cholesky.cpp:26
ceil
const EIGEN_DEVICE_FUNC CeilReturnType ceil() const
Definition: ArrayCwiseUnaryOps.h:402
Eigen::internal::is_same
Definition: Meta.h:63
Eigen::EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE
const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename Derived::Scalar, Derived, pow) pow(const typename Derived
Definition: GlobalFunctions.h:168
Eigen::internal::plain_constant_type::type
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:635
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::enable_if
Definition: Meta.h:184
round
const EIGEN_DEVICE_FUNC RoundReturnType round() const
Definition: ArrayCwiseUnaryOps.h:374
sinh
const EIGEN_DEVICE_FUNC SinhReturnType sinh() const
Definition: ArrayCwiseUnaryOps.h:304
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME, FUNCTOR, DOC_OP, DOC_DETAILS)
Definition: GlobalFunctions.h:29
Eigen::EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE
const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived, typename Derived::Scalar, pow) pow(const Eigen
Definition: GlobalFunctions.h:113
cos
const EIGEN_DEVICE_FUNC CosReturnType cos() const
Definition: ArrayCwiseUnaryOps.h:202
Eigen::half_impl::isnan
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool() isnan(const half &a)
Definition: Half.h:434
log10
const EIGEN_DEVICE_FUNC Log10ReturnType log10() const
Definition: ArrayCwiseUnaryOps.h:135
floor
const EIGEN_DEVICE_FUNC FloorReturnType floor() const
Definition: ArrayCwiseUnaryOps.h:388
cwiseAbs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE CwiseAbsReturnType cwiseAbs() const
Definition: MatrixCwiseUnaryOps.h:32
complex
Definition: datatypes.h:12
EIGEN_SCALAR_BINARY_SUPPORTED
#define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME, TYPEA, TYPEB)
Definition: Macros.h:923
Eigen::internal::is_same::value
@ value
Definition: Meta.h:63


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:47