MOAB
4.9.3pre
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008-2009 Gael Guennebaud <[email protected]> 00005 // Copyright (C) 2006-2008 Benoit Jacob <[email protected]> 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 CwiseUnaryOp<internal::scalar_multiple_op<Scalar>, const Derived> ScalarMultipleReturnType; 00017 typedef CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived> ScalarComplexMultipleReturnType; 00018 00020 typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived> ScalarQuotient1ReturnType; 00022 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex, 00023 const CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Derived>, 00024 const Derived& 00025 >::type ConjugateReturnType; 00027 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex, 00028 const CwiseUnaryOp<internal::scalar_real_op<Scalar>, const Derived>, 00029 const Derived& 00030 >::type RealReturnType; 00032 typedef typename internal::conditional<NumTraits<Scalar>::IsComplex, 00033 CwiseUnaryView<internal::scalar_real_ref_op<Scalar>, Derived>, 00034 Derived& 00035 >::type NonConstRealReturnType; 00037 typedef CwiseUnaryOp<internal::scalar_imag_op<Scalar>, const Derived> ImagReturnType; 00039 typedef CwiseUnaryView<internal::scalar_imag_ref_op<Scalar>, Derived> NonConstImagReturnType; 00040 00041 typedef CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const Derived> NegativeReturnType; 00042 //typedef CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>, const Derived> 00043 00044 #endif // not EIGEN_PARSED_BY_DOXYGEN 00045 00048 EIGEN_DEVICE_FUNC 00049 inline const NegativeReturnType 00050 operator-() const { return NegativeReturnType(derived()); } 00051 00052 00054 EIGEN_DEVICE_FUNC 00055 inline const ScalarMultipleReturnType 00056 operator*(const Scalar& scalar) const 00057 { 00058 return ScalarMultipleReturnType(derived(), internal::scalar_multiple_op<Scalar>(scalar)); 00059 } 00060 00061 #ifdef EIGEN_PARSED_BY_DOXYGEN 00062 const ScalarMultipleReturnType operator*(const RealScalar& scalar) const; 00063 #endif 00064 00066 EIGEN_DEVICE_FUNC 00067 inline const ScalarQuotient1ReturnType 00068 operator/(const Scalar& scalar) const 00069 { 00070 return ScalarQuotient1ReturnType(derived(), internal::scalar_quotient1_op<Scalar>(scalar)); 00071 } 00072 00074 EIGEN_DEVICE_FUNC 00075 inline const ScalarComplexMultipleReturnType 00076 operator*(const std::complex<Scalar>& scalar) const 00077 { 00078 return ScalarComplexMultipleReturnType(derived(), internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >(scalar)); 00079 } 00080 00081 EIGEN_DEVICE_FUNC 00082 inline friend const ScalarMultipleReturnType 00083 operator*(const Scalar& scalar, const StorageBaseType& matrix) 00084 { return matrix*scalar; } 00085 00086 EIGEN_DEVICE_FUNC 00087 inline friend const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived> 00088 operator*(const std::complex<Scalar>& scalar, const StorageBaseType& matrix) 00089 { return matrix*scalar; } 00090 00091 00092 template<class NewType> struct CastXpr { typedef typename internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<Scalar, NewType>, const Derived> >::type Type; }; 00093 00101 template<typename NewType> 00102 EIGEN_DEVICE_FUNC 00103 typename CastXpr<NewType>::Type 00104 cast() const 00105 { 00106 return typename CastXpr<NewType>::Type(derived()); 00107 } 00108 00112 EIGEN_DEVICE_FUNC 00113 inline ConjugateReturnType 00114 conjugate() const 00115 { 00116 return ConjugateReturnType(derived()); 00117 } 00118 00122 EIGEN_DEVICE_FUNC 00123 inline RealReturnType 00124 real() const { return RealReturnType(derived()); } 00125 00129 EIGEN_DEVICE_FUNC 00130 inline const ImagReturnType 00131 imag() const { return ImagReturnType(derived()); } 00132 00152 template<typename CustomUnaryOp> 00153 EIGEN_DEVICE_FUNC 00154 inline const CwiseUnaryOp<CustomUnaryOp, const Derived> 00155 unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const 00156 { 00157 return CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func); 00158 } 00159 00171 template<typename CustomViewOp> 00172 EIGEN_DEVICE_FUNC 00173 inline const CwiseUnaryView<CustomViewOp, const Derived> 00174 unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const 00175 { 00176 return CwiseUnaryView<CustomViewOp, const Derived>(derived(), func); 00177 } 00178 00182 EIGEN_DEVICE_FUNC 00183 inline NonConstRealReturnType 00184 real() { return NonConstRealReturnType(derived()); } 00185 00189 EIGEN_DEVICE_FUNC 00190 inline NonConstImagReturnType 00191 imag() { return NonConstImagReturnType(derived()); }