Medial Code Documentation
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 CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived> ScalarMultipleReturnType;
17typedef CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived> ScalarComplexMultipleReturnType;
18
20typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived> ScalarQuotient1ReturnType;
22typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
23 const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
24 const Derived&
25 >::type ConjugateReturnType;
27typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
28 const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
29 const Derived&
30 >::type RealReturnType;
32typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
33 CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
34 Derived&
35 >::type NonConstRealReturnType;
37typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
39typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
40
41typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType;
42//typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived>
43
44#endif // not EIGEN_PARSED_BY_DOXYGEN
45
48EIGEN_DEVICE_FUNC
49inline const NegativeReturnType
50operator-() const { return NegativeReturnType(derived()); }
51
52
54EIGEN_DEVICE_FUNC
55inline const ScalarMultipleReturnType
56operator*(const Scalar& scalar) const
57{
58 return ScalarMultipleReturnType(derived(), internal::scalar_multiple_op<Scalar>(scalar));
59}
60
61#ifdef EIGEN_PARSED_BY_DOXYGEN
62const ScalarMultipleReturnType operator*(const RealScalar& scalar) const;
63#endif
64
66EIGEN_DEVICE_FUNC
67inline const ScalarQuotient1ReturnType
68operator/(const Scalar& scalar) const
69{
70 return ScalarQuotient1ReturnType(derived(), internal::scalar_quotient1_op<Scalar>(scalar));
71}
72
74EIGEN_DEVICE_FUNC
75inline const ScalarComplexMultipleReturnType
76operator*(const std::complex<Scalar>& scalar) const
77{
78 return ScalarComplexMultipleReturnType(derived(), internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >(scalar));
79}
80
81EIGEN_DEVICE_FUNC
82inline friend const ScalarMultipleReturnType
83operator*(const Scalar& scalar, const StorageBaseType& matrix)
84{ return matrix*scalar; }
85
86EIGEN_DEVICE_FUNC
87inline friend const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
88operator*(const std::complex<Scalar>& scalar, const StorageBaseType& matrix)
89{ return matrix*scalar; }
90
91
92template<class NewType> struct CastXpr { typedef typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<Scalar, NewType>, const Derived> >::type Type; };
93
101template<typename NewType>
102EIGEN_DEVICE_FUNC
103typename CastXpr<NewType>::Type
104cast() const
105{
106 return typename CastXpr<NewType>::Type(derived());
107}
108
112EIGEN_DEVICE_FUNC
113inline ConjugateReturnType
114conjugate() const
115{
116 return ConjugateReturnType(derived());
117}
118
122EIGEN_DEVICE_FUNC
123inline RealReturnType
124real() const { return RealReturnType(derived()); }
125
129EIGEN_DEVICE_FUNC
130inline const ImagReturnType
131imag() const { return ImagReturnType(derived()); }
132
152template<typename CustomUnaryOp>
153EIGEN_DEVICE_FUNC
154inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
155unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
156{
157 return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
158}
159
171template<typename CustomViewOp>
172EIGEN_DEVICE_FUNC
173inline const CwiseUnaryView<CustomViewOp, const Derived>
174unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
175{
176 return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
177}
178
182EIGEN_DEVICE_FUNC
183inline NonConstRealReturnType
184real() { return NonConstRealReturnType(derived()); }
185
189EIGEN_DEVICE_FUNC
190inline NonConstImagReturnType
191imag() { return NonConstImagReturnType(derived()); }
Definition CommonCwiseUnaryOps.h:92