CwiseUnaryOp.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) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 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_CWISE_UNARY_OP_H
12 #define EIGEN_CWISE_UNARY_OP_H
13 
14 // IWYU pragma: private
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
19 namespace internal {
20 template <typename UnaryOp, typename XprType>
21 struct traits<CwiseUnaryOp<UnaryOp, XprType> > : traits<XprType> {
22  typedef typename result_of<UnaryOp(const typename XprType::Scalar&)>::type Scalar;
23  typedef typename XprType::Nested XprTypeNested;
24  typedef std::remove_reference_t<XprTypeNested> XprTypeNested_;
25  enum { Flags = XprTypeNested_::Flags & RowMajorBit };
26 };
27 } // namespace internal
28 
29 template <typename UnaryOp, typename XprType, typename StorageKind>
30 class CwiseUnaryOpImpl;
31 
51 template <typename UnaryOp, typename XprType>
52 class CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>,
54  public:
57  typedef typename internal::ref_selector<XprType>::type XprTypeNested;
59 
60  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())
61  : m_xpr(xpr), m_functor(func) {}
62 
65 
67  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& functor() const { return m_functor; }
68 
71  return m_xpr;
72  }
73 
76 
77  protected:
79  const UnaryOp m_functor;
80 };
81 
82 // Generic API dispatcher
83 template <typename UnaryOp, typename XprType, typename StorageKind>
84 class CwiseUnaryOpImpl : public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type {
85  public:
87 };
88 
89 } // end namespace Eigen
90 
91 #endif // EIGEN_CWISE_UNARY_OP_H
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1149
#define EIGEN_NOEXCEPT
Definition: Macros.h:1267
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
SCALAR Scalar
Definition: bench_gemm.cpp:45
Definition: CwiseUnaryOp.h:84
internal::generic_xpr_base< CwiseUnaryOp< UnaryOp, XprType > >::type Base
Definition: CwiseUnaryOp.h:86
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:53
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: CwiseUnaryOp.h:64
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_all_t< XprTypeNested > & nestedExpression()
Definition: CwiseUnaryOp.h:75
internal::remove_all_t< XprType > NestedExpression
Definition: CwiseUnaryOp.h:58
internal::ref_selector< XprType >::type XprTypeNested
Definition: CwiseUnaryOp.h:57
const UnaryOp m_functor
Definition: CwiseUnaryOp.h:79
XprTypeNested m_xpr
Definition: CwiseUnaryOp.h:78
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp & functor() const
Definition: CwiseUnaryOp.h:67
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all_t< XprTypeNested > & nestedExpression() const
Definition: CwiseUnaryOp.h:70
CwiseUnaryOpImpl< UnaryOp, XprType, typename internal::traits< XprType >::StorageKind >::Base Base
Definition: CwiseUnaryOp.h:55
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: CwiseUnaryOp.h:63
Definition: XprHelper.h:134
const unsigned int RowMajorBit
Definition: Constants.h:70
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
Definition: nestbyvalue.cpp:15
Definition: XprHelper.h:575
Definition: Meta.h:388
XprType::Nested XprTypeNested
Definition: CwiseUnaryOp.h:23
result_of< UnaryOp(const typename XprType::Scalar &)>::type Scalar
Definition: CwiseUnaryOp.h:22
std::remove_reference_t< XprTypeNested > XprTypeNested_
Definition: CwiseUnaryOp.h:24
Definition: ForwardDeclarations.h:21
Definition: benchGeometry.cpp:21