CommonCwiseUnaryOps.h
Go to the documentation of this file.
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 // Eigen is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public
00009 // License as published by the Free Software Foundation; either
00010 // version 3 of the License, or (at your option) any later version.
00011 //
00012 // Alternatively, you can redistribute it and/or
00013 // modify it under the terms of the GNU General Public License as
00014 // published by the Free Software Foundation; either version 2 of
00015 // the License, or (at your option) any later version.
00016 //
00017 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00018 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00019 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License and a copy of the GNU General Public License along with
00024 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00025 
00026 // This file is a base class plugin containing common coefficient wise functions.
00027 
00028 #ifndef EIGEN_PARSED_BY_DOXYGEN
00029 
00031 typedef CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived> ScalarMultipleReturnType;
00033 typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived> ScalarQuotient1ReturnType;
00035 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00036                     const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>,
00037                     const Derived&
00038                   >::type ConjugateReturnType;
00040 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00041                     const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>,
00042                     const Derived&
00043                   >::type RealReturnType;
00045 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00046                     CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>,
00047                     Derived&
00048                   >::type NonConstRealReturnType;
00050 typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType;
00052 typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType;
00053 
00054 #endif // not EIGEN_PARSED_BY_DOXYGEN
00055 
00058 inline const CwiseUnaryOp<internal::scalar_opposite_op<typename internal::traits<Derived>::Scalar>, const Derived>
00059 operator-() const { return derived(); }
00060 
00061 
00063 inline const ScalarMultipleReturnType
00064 operator*(const Scalar& scalar) const
00065 {
00066   return CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived>
00067     (derived(), internal::scalar_multiple_op<Scalar>(scalar));
00068 }
00069 
00070 #ifdef EIGEN_PARSED_BY_DOXYGEN
00071 const ScalarMultipleReturnType operator*(const RealScalar& scalar) const;
00072 #endif
00073 
00075 inline const CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>, const Derived>
00076 operator/(const Scalar& scalar) const
00077 {
00078   return CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived>
00079     (derived(), internal::scalar_quotient1_op<Scalar>(scalar));
00080 }
00081 
00083 inline const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
00084 operator*(const std::complex<Scalar>& scalar) const
00085 {
00086   return CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
00087     (*static_cast<const Derived*>(this), internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >(scalar));
00088 }
00089 
00090 inline friend const ScalarMultipleReturnType
00091 operator*(const Scalar& scalar, const StorageBaseType& matrix)
00092 { return matrix*scalar; }
00093 
00094 inline friend const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived>
00095 operator*(const std::complex<Scalar>& scalar, const StorageBaseType& matrix)
00096 { return matrix*scalar; }
00097 
00105 template<typename NewType>
00106 typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<typename internal::traits<Derived>::Scalar, NewType>, const Derived> >::type
00107 cast() const
00108 {
00109   return derived();
00110 }
00111 
00115 inline ConjugateReturnType
00116 conjugate() const
00117 {
00118   return ConjugateReturnType(derived());
00119 }
00120 
00124 inline RealReturnType
00125 real() const { return derived(); }
00126 
00130 inline const ImagReturnType
00131 imag() const { return derived(); }
00132 
00152 template<typename CustomUnaryOp>
00153 inline const CwiseUnaryOp<CustomUnaryOp, const Derived>
00154 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const
00155 {
00156   return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
00157 }
00158 
00170 template<typename CustomViewOp>
00171 inline const CwiseUnaryView<CustomViewOp, const Derived>
00172 unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const
00173 {
00174   return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
00175 }
00176 
00180 inline NonConstRealReturnType
00181 real() { return derived(); }
00182 
00186 inline NonConstImagReturnType
00187 imag() { return derived(); }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:57