Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
CwiseUnaryOp.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2014 Gael Guennebaud <[email protected]>
5// Copyright (C) 2006-2008 Benoit Jacob <[email protected]>
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
17namespace Eigen {
18
19namespace internal {
20template <typename UnaryOp, typename XprType>
21struct 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
29template <typename UnaryOp, typename XprType, typename StorageKind>
30class CwiseUnaryOpImpl;
31
51template <typename UnaryOp, typename XprType>
52class CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>,
53 internal::no_assignment_operator {
54 public:
55 typedef typename CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>::Base Base;
56 EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
57 typedef typename internal::ref_selector<XprType>::type XprTypeNested;
58 typedef internal::remove_all_t<XprType> NestedExpression;
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
63 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
64 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
65
67 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& functor() const { return m_functor; }
68
70 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all_t<XprTypeNested>& nestedExpression() const {
71 return m_xpr;
72 }
73
75 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_all_t<XprTypeNested>& nestedExpression() { return m_xpr; }
76
77 protected:
78 XprTypeNested m_xpr;
79 const UnaryOp m_functor;
80};
81
82// Generic API dispatcher
83template <typename UnaryOp, typename XprType, typename StorageKind>
84class CwiseUnaryOpImpl : public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type {
85 public:
86 typedef typename internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;
87};
88
89} // end namespace Eigen
90
91#endif // EIGEN_CWISE_UNARY_OP_H
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition CwiseUnaryOp.h:53
const internal::remove_all_t< XprTypeNested > & nestedExpression() const
Definition CwiseUnaryOp.h:70
internal::remove_all_t< XprTypeNested > & nestedExpression()
Definition CwiseUnaryOp.h:75
const UnaryOp & functor() const
Definition CwiseUnaryOp.h:67
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83