Eigen  3.3.3
CommonCwiseUnaryOps.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 // This file is a base class plugin containing common coefficient wise functions.
00012 
00013 #ifndef EIGEN_PARSED_BY_DOXYGEN
00014 
00016 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00017                     const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
00018                     const Derived&
00019                   >::type ConjugateReturnType;
00021 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00022                     const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
00023                     const Derived&
00024                   >::type RealReturnType;
00026 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00027                     CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
00028                     Derived&
00029                   >::type NonConstRealReturnType;
00031 typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
00033 typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
00034 
00035 typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType;
00036 
00037 #endif // not EIGEN_PARSED_BY_DOXYGEN
00038 
00041 EIGEN_DOC_UNARY_ADDONS(operator-,opposite)
00043 EIGEN_DEVICE_FUNC
00044 inline const NegativeReturnType
00045 operator-() const { return NegativeReturnType(derived()); }
00046 
00047 
00048 template<class NewType> struct CastXpr { typedef typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<Scalar, NewType>, const Derived> >::type Type; };
00049 
00055 EIGEN_DOC_UNARY_ADDONS(cast,conversion function)
00059 template<typename NewType>
00060 EIGEN_DEVICE_FUNC
00061 typename CastXpr<NewType>::Type
00062 cast() const
00063 {
00064   return typename CastXpr<NewType>::Type(derived());
00065 }
00066 
00069 EIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate)
00072 EIGEN_DEVICE_FUNC
00073 inline ConjugateReturnType
00074 conjugate() const
00075 {
00076   return ConjugateReturnType(derived());
00077 }
00078 
00081 EIGEN_DOC_UNARY_ADDONS(real,real part function)
00084 EIGEN_DEVICE_FUNC
00085 inline RealReturnType
00086 real() const { return RealReturnType(derived()); }
00087 
00090 EIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)
00093 EIGEN_DEVICE_FUNC
00094 inline const ImagReturnType
00095 imag() const { return ImagReturnType(derived()); }
00096 
00114 EIGEN_DOC_UNARY_ADDONS(unaryExpr,unary function)
00118 template<typename CustomUnaryOp>
00119 EIGEN_DEVICE_FUNC
00120 inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
00121 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
00122 {
00123   return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
00124 }
00125 
00135 EIGEN_DOC_UNARY_ADDONS(unaryViewExpr,unary function)
00139 template<typename CustomViewOp>
00140 EIGEN_DEVICE_FUNC
00141 inline const CwiseUnaryView<CustomViewOp, const Derived>
00142 unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
00143 {
00144   return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
00145 }
00146 
00149 EIGEN_DOC_UNARY_ADDONS(real,real part function)
00152 EIGEN_DEVICE_FUNC
00153 inline NonConstRealReturnType
00154 real() { return NonConstRealReturnType(derived()); }
00155 
00158 EIGEN_DOC_UNARY_ADDONS(imag,imaginary part function)
00161 EIGEN_DEVICE_FUNC
00162 inline NonConstImagReturnType
00163 imag() { return NonConstImagReturnType(derived()); }
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends