Eigen  3.2.7
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 <[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 // This file is a base class plugin containing common coefficient wise functions.
12 
13 #ifndef EIGEN_PARSED_BY_DOXYGEN
14 
16 typedef CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived> ScalarMultipleReturnType;
18 typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived> ScalarQuotient1ReturnType;
20 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
21  const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
22  const Derived&
23  >::type ConjugateReturnType;
25 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
26  const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
27  const Derived&
28  >::type RealReturnType;
30 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
31  CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
32  Derived&
33  >::type NonConstRealReturnType;
35 typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
37 typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
38 
39 #endif // not EIGEN_PARSED_BY_DOXYGEN
40 
43 inline const CwiseUnaryOp<internal::scalar_opposite_op<typename internal::traits<Derived>::Scalar>, const Derived>
44 operator-() const { return derived(); }
45 
46 
48 inline const ScalarMultipleReturnType
49 operator*(const Scalar& scalar) const
50 {
51  return CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived>
52  (derived(), internal::scalar_multiple_op<Scalar>(scalar));
53 }
54 
55 #ifdef EIGEN_PARSED_BY_DOXYGEN
56 const ScalarMultipleReturnType operator*(const RealScalar& scalar) const;
57 #endif
58 
60 inline const CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>, const Derived>
61 operator/(const Scalar& scalar) const
62 {
63  return CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived>
64  (derived(), internal::scalar_quotient1_op<Scalar>(scalar));
65 }
66 
68 inline const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
69 operator*(const std::complex<Scalar>& scalar) const
70 {
71  return CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
72  (*static_cast<const Derived*>(this), internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >(scalar));
73 }
74 
75 inline friend const ScalarMultipleReturnType
76 operator*(const Scalar& scalar, const StorageBaseType& matrix)
77 { return matrix*scalar; }
78 
79 inline friend const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
80 operator*(const std::complex<Scalar>& scalar, const StorageBaseType& matrix)
81 { return matrix*scalar; }
82 
90 template<typename NewType>
91 typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<typename internal::traits<Derived>::Scalar, NewType>, const Derived> >::type
92 cast() const
93 {
94  return derived();
95 }
96 
100 inline ConjugateReturnType
101 conjugate() const
102 {
103  return ConjugateReturnType(derived());
104 }
105 
109 inline RealReturnType
110 real() const { return derived(); }
111 
115 inline const ImagReturnType
116 imag() const { return derived(); }
117 
137 template<typename CustomUnaryOp>
138 inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
139 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
140 {
141  return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
142 }
143 
155 template<typename CustomViewOp>
156 inline const CwiseUnaryView<CustomViewOp, const Derived>
157 unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
158 {
159  return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
160 }
161 
165 inline NonConstRealReturnType
166 real() { return derived(); }
167 
171 inline NonConstImagReturnType
172 imag() { return derived(); }
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_mult_op< typename Derived::Scalar >, const Derived > operator/(const typename Derived::Scalar &s, const Eigen::ArrayBase< Derived > &a)
Component-wise division of a scalar by array elements.
Definition: GlobalFunctions.h:74
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:539