Medial Code Documentation
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 <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
14namespace Eigen {
15
16namespace internal {
17template<typename UnaryOp, typename XprType>
18struct traits<CwiseUnaryOp<UnaryOp, XprType> >
19 : traits<XprType>
20{
21 typedef typename result_of<
22 UnaryOp(const typename XprType::Scalar&)
23 >::type Scalar;
24 typedef typename XprType::Nested XprTypeNested;
25 typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;
26 enum {
27 Flags = _XprTypeNested::Flags & RowMajorBit
28 };
29};
30}
31
32template<typename UnaryOp, typename XprType, typename StorageKind>
34
54template<typename UnaryOp, typename XprType>
55class CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>, internal::no_assignment_operator
56{
57 public:
58
60 EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
62 typedef typename internal::remove_all<XprType>::type NestedExpression;
63
64 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
65 explicit CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())
66 : m_xpr(xpr), m_functor(func) {}
67
68 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
69 Index rows() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
70 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
71 Index cols() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
72
74 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
75 const UnaryOp& functor() const { return m_functor; }
76
78 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
79 const typename internal::remove_all<XprTypeNested>::type&
80 nestedExpression() const { return m_xpr; }
81
83 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
84 typename internal::remove_all<XprTypeNested>::type&
85 nestedExpression() { return m_xpr; }
86
87 protected:
88 XprTypeNested m_xpr;
89 const UnaryOp m_functor;
90};
91
92// Generic API dispatcher
93template<typename UnaryOp, typename XprType, typename StorageKind>
95 : public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type
96{
97public:
99};
100
101} // end namespace Eigen
102
103#endif // EIGEN_CWISE_UNARY_OP_H
Definition CwiseUnaryOp.h:96
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition CwiseUnaryOp.h:56
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp & functor() const
Definition CwiseUnaryOp.h:75
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< XprTypeNested >::type & nestedExpression() const
Definition CwiseUnaryOp.h:80
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::remove_all< XprTypeNested >::type & nestedExpression()
Definition CwiseUnaryOp.h:85
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Definition XprHelper.h:110
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Definition XprHelper.h:501
Definition Meta.h:514
Definition ForwardDeclarations.h:17
Definition Meta.h:96