Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
0005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
0006 //
0007 // This Source Code Form is subject to the terms of the Mozilla
0008 // Public License v. 2.0. If a copy of the MPL was not distributed
0009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0010 
0011 // This file is a base class plugin containing common coefficient wise functions.
0012 
0013 #ifndef EIGEN_PARSED_BY_DOXYGEN
0014 
0015 /** \internal the return type of conjugate() */
0016 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
0017                     const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
0018                     const Derived&
0019                   >::type ConjugateReturnType;
0020 /** \internal the return type of real() const */
0021 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
0022                     const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
0023                     const Derived&
0024                   >::type RealReturnType;
0025 /** \internal the return type of real() */
0026 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
0027                     CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
0028                     Derived&
0029                   >::type NonConstRealReturnType;
0030 /** \internal the return type of imag() const */
0031 typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
0032 /** \internal the return type of imag() */
0033 typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
0034 
0035 typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType;
0036 
0037 #endif // not EIGEN_PARSED_BY_DOXYGEN
0038 
0039 /// \returns an expression of the opposite of \c *this
0040 ///
0041 EIGEN_DOC_UNARY_ADDONS(operator-,opposite)
0042 ///
0043 EIGEN_DEVICE_FUNC
0044 inline const NegativeReturnType
0045 operator-() const { return NegativeReturnType(derived()); }
0046 
0047 
0048 template<class NewType> struct CastXpr { typedef typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<Scalar, NewType>, const Derived> >::type Type; };
0049 
0050 /// \returns an expression of \c *this with the \a Scalar type casted to
0051 /// \a NewScalar.
0052 ///
0053 /// The template parameter \a NewScalar is the type we are casting the scalars to.
0054 ///
0055 EIGEN_DOC_UNARY_ADDONS(cast,conversion function)
0056 ///
0057 /// \sa class CwiseUnaryOp
0058 ///
0059 template<typename NewType>
0060 EIGEN_DEVICE_FUNC
0061 typename CastXpr<NewType>::Type
0062 cast() const
0063 {
0064   return typename CastXpr<NewType>::Type(derived());
0065 }
0066 
0067 /// \returns an expression of the complex conjugate of \c *this.
0068 ///
0069 EIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate)
0070 ///
0071 /// \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_conj">Math functions</a>, MatrixBase::adjoint()
0072 EIGEN_DEVICE_FUNC
0073 inline ConjugateReturnType
0074 conjugate() const
0075 {
0076   return ConjugateReturnType(derived());
0077 }
0078 
0079 /// \returns an expression of the complex conjugate of \c *this if Cond==true, returns derived() otherwise.
0080 ///
0081 EIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate)
0082 ///
0083 /// \sa conjugate()
0084 template<bool Cond>
0085 EIGEN_DEVICE_FUNC
0086 inline typename internal::conditional<Cond,ConjugateReturnType,const Derived&>::type
0087 conjugateIf() const
0088 {
0089   typedef typename internal::conditional<Cond,ConjugateReturnType,const Derived&>::type ReturnType;
0090   return ReturnType(derived());
0091 }
0092 
0093 /// \returns a read-only expression of the real part of \c *this.
0094 ///
0095 EIGEN_DOC_UNARY_ADDONS(real,real part function)
0096 ///
0097 /// \sa imag()
0098 EIGEN_DEVICE_FUNC
0099 inline RealReturnType
0100 real() const { return RealReturnType(derived()); }
0101 
0102 /// \returns an read-only expression of the imaginary part of \c *this.
0103 ///
0104 EIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)
0105 ///
0106 /// \sa real()
0107 EIGEN_DEVICE_FUNC
0108 inline const ImagReturnType
0109 imag() const { return ImagReturnType(derived()); }
0110 
0111 /// \brief Apply a unary operator coefficient-wise
0112 /// \param[in]  func  Functor implementing the unary operator
0113 /// \tparam  CustomUnaryOp Type of \a func
0114 /// \returns An expression of a custom coefficient-wise unary operator \a func of *this
0115 ///
0116 /// The function \c ptr_fun() from the C++ standard library can be used to make functors out of normal functions.
0117 ///
0118 /// Example:
0119 /// \include class_CwiseUnaryOp_ptrfun.cpp
0120 /// Output: \verbinclude class_CwiseUnaryOp_ptrfun.out
0121 ///
0122 /// Genuine functors allow for more possibilities, for instance it may contain a state.
0123 ///
0124 /// Example:
0125 /// \include class_CwiseUnaryOp.cpp
0126 /// Output: \verbinclude class_CwiseUnaryOp.out
0127 ///
0128 EIGEN_DOC_UNARY_ADDONS(unaryExpr,unary function)
0129 ///
0130 /// \sa unaryViewExpr, binaryExpr, class CwiseUnaryOp
0131 ///
0132 template<typename CustomUnaryOp>
0133 EIGEN_DEVICE_FUNC
0134 inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
0135 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
0136 {
0137   return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
0138 }
0139 
0140 /// \returns an expression of a custom coefficient-wise unary operator \a func of *this
0141 ///
0142 /// The template parameter \a CustomUnaryOp is the type of the functor
0143 /// of the custom unary operator.
0144 ///
0145 /// Example:
0146 /// \include class_CwiseUnaryOp.cpp
0147 /// Output: \verbinclude class_CwiseUnaryOp.out
0148 ///
0149 EIGEN_DOC_UNARY_ADDONS(unaryViewExpr,unary function)
0150 ///
0151 /// \sa unaryExpr, binaryExpr class CwiseUnaryOp
0152 ///
0153 template<typename CustomViewOp>
0154 EIGEN_DEVICE_FUNC
0155 inline const CwiseUnaryView<CustomViewOp, const Derived>
0156 unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
0157 {
0158   return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
0159 }
0160 
0161 /// \returns a non const expression of the real part of \c *this.
0162 ///
0163 EIGEN_DOC_UNARY_ADDONS(real,real part function)
0164 ///
0165 /// \sa imag()
0166 EIGEN_DEVICE_FUNC
0167 inline NonConstRealReturnType
0168 real() { return NonConstRealReturnType(derived()); }
0169 
0170 /// \returns a non const expression of the imaginary part of \c *this.
0171 ///
0172 EIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)
0173 ///
0174 /// \sa real()
0175 EIGEN_DEVICE_FUNC
0176 inline NonConstImagReturnType
0177 imag() { return NonConstImagReturnType(derived()); }