Eigen  3.4.90 (git rev 9589cc4e7fd8e4538bedef80dd36c7738977a8be)
 
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Loading...
Searching...
No Matches
CommonCwiseUnaryOps.inc
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 std::conditional_t<NumTraits<Scalar>::IsComplex,
17 const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>, const Derived&>
18 ConjugateReturnType;
20typedef std::conditional_t<NumTraits<Scalar>::IsComplex,
21 const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>, const Derived&>
22 RealReturnType;
24typedef std::conditional_t<NumTraits<Scalar>::IsComplex, CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
25 Derived&>
26 NonConstRealReturnType;
28typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
30typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
31
32typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType;
33
34#endif // not EIGEN_PARSED_BY_DOXYGEN
35
38EIGEN_DOC_UNARY_ADDONS(operator-, opposite)
40EIGEN_DEVICE_FUNC inline const NegativeReturnType operator-() const { return NegativeReturnType(derived()); }
41
42template <class NewType>
43struct CastXpr {
44 typedef typename internal::cast_return_type<
45 Derived, const CwiseUnaryOp<internal::core_cast_op<Scalar, NewType>, const Derived> >::type Type;
46};
47
53EIGEN_DOC_UNARY_ADDONS(cast, conversion function)
57template <typename NewType>
58EIGEN_DEVICE_FUNC typename CastXpr<NewType>::Type cast() const {
59 return typename CastXpr<NewType>::Type(derived());
60}
61
64EIGEN_DOC_UNARY_ADDONS(conjugate, complex conjugate)
67EIGEN_DEVICE_FUNC inline ConjugateReturnType conjugate() const { return ConjugateReturnType(derived()); }
68
71EIGEN_DOC_UNARY_ADDONS(conjugate, complex conjugate)
74template <bool Cond>
75EIGEN_DEVICE_FUNC inline std::conditional_t<Cond, ConjugateReturnType, const Derived&> conjugateIf() const {
76 typedef std::conditional_t<Cond, ConjugateReturnType, const Derived&> ReturnType;
77 return ReturnType(derived());
78}
79
82EIGEN_DOC_UNARY_ADDONS(real, real part function)
85EIGEN_DEVICE_FUNC inline RealReturnType real() const { return RealReturnType(derived()); }
86
89EIGEN_DOC_UNARY_ADDONS(imag, imaginary part function)
92EIGEN_DEVICE_FUNC inline const ImagReturnType imag() const { return ImagReturnType(derived()); }
93
111EIGEN_DOC_UNARY_ADDONS(unaryExpr, unary function)
115template <typename CustomUnaryOp>
116EIGEN_DEVICE_FUNC inline const CwiseUnaryOp<CustomUnaryOp, const Derived> unaryExpr(
117 const CustomUnaryOp& func = CustomUnaryOp()) const {
118 return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
119}
120
130EIGEN_DOC_UNARY_ADDONS(unaryViewExpr, unary function)
134template <typename CustomViewOp>
135EIGEN_DEVICE_FUNC inline const CwiseUnaryView<CustomViewOp, const Derived> unaryViewExpr(
136 const CustomViewOp& func = CustomViewOp()) const {
137 return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
138}
139
145EIGEN_DOC_UNARY_ADDONS(unaryViewExpr, unary function)
149template <typename CustomViewOp>
150EIGEN_DEVICE_FUNC inline CwiseUnaryView<CustomViewOp, Derived> unaryViewExpr(
151 const CustomViewOp& func = CustomViewOp()) {
152 return CwiseUnaryView<CustomViewOp, Derived>(derived(), func);
153}
154
157EIGEN_DOC_UNARY_ADDONS(real, real part function)
160EIGEN_DEVICE_FUNC inline NonConstRealReturnType real() { return NonConstRealReturnType(derived()); }
161
164EIGEN_DOC_UNARY_ADDONS(imag, imaginary part function)
167EIGEN_DEVICE_FUNC inline NonConstImagReturnType imag() { 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)