Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
Loading...
Searching...
No Matches
CommonCwiseUnaryOps.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2009 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// This file is a base class plugin containing common coefficient wise functions.
12
13#ifndef EIGEN_PARSED_BY_DOXYGEN
14
16typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
17 const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
18 const Derived&
19 >::type ConjugateReturnType;
21typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
22 const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
23 const Derived&
24 >::type RealReturnType;
26typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
27 CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
28 Derived&
29 >::type NonConstRealReturnType;
31typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
33typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
34
35typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType;
36
37#endif // not EIGEN_PARSED_BY_DOXYGEN
38
41EIGEN_DOC_UNARY_ADDONS(operator-,opposite)
43EIGEN_DEVICE_FUNC
44inline const NegativeReturnType
45operator-() const { return NegativeReturnType(derived()); }
46
47
48template<class NewType> struct CastXpr { typedef typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<Scalar, NewType>, const Derived> >::type Type; };
49
55EIGEN_DOC_UNARY_ADDONS(cast,conversion function)
59template<typename NewType>
60EIGEN_DEVICE_FUNC
61typename CastXpr<NewType>::Type
62cast() const
63{
64 return typename CastXpr<NewType>::Type(derived());
65}
66
69EIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate)
72EIGEN_DEVICE_FUNC
73inline ConjugateReturnType
74conjugate() const
75{
76 return ConjugateReturnType(derived());
77}
78
81EIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate)
84template<bool Cond>
85EIGEN_DEVICE_FUNC
86inline typename internal::conditional<Cond,ConjugateReturnType,const Derived&>::type
87conjugateIf() const
88{
89 typedef typename internal::conditional<Cond,ConjugateReturnType,const Derived&>::type ReturnType;
90 return ReturnType(derived());
91}
92
95EIGEN_DOC_UNARY_ADDONS(real,real part function)
98EIGEN_DEVICE_FUNC
99inline RealReturnType
100real() const { return RealReturnType(derived()); }
101
104EIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)
107EIGEN_DEVICE_FUNC
108inline const ImagReturnType
109imag() const { return ImagReturnType(derived()); }
110
128EIGEN_DOC_UNARY_ADDONS(unaryExpr,unary function)
132template<typename CustomUnaryOp>
133EIGEN_DEVICE_FUNC
134inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
135unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
136{
137 return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
138}
139
149EIGEN_DOC_UNARY_ADDONS(unaryViewExpr,unary function)
153template<typename CustomViewOp>
154EIGEN_DEVICE_FUNC
155inline const CwiseUnaryView<CustomViewOp, const Derived>
156unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
157{
158 return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
159}
160
163EIGEN_DOC_UNARY_ADDONS(real,real part function)
166EIGEN_DEVICE_FUNC
167inline NonConstRealReturnType
168real() { return NonConstRealReturnType(derived()); }
169
172EIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)
175EIGEN_DEVICE_FUNC
176inline NonConstImagReturnType
177imag() { return NonConstImagReturnType(derived()); }
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_real_op< typename Derived::Scalar >, const Derived > real(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_imag_op< typename Derived::Scalar >, const Derived > imag(const Eigen::ArrayBase< Derived > &x)