Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EIGEN_NOALIAS_H
00026 #define EIGEN_NOALIAS_H
00027
00028 namespace Eigen {
00029
00045 template<typename ExpressionType, template <typename> class StorageBase>
00046 class NoAlias
00047 {
00048 typedef typename ExpressionType::Scalar Scalar;
00049 public:
00050 NoAlias(ExpressionType& expression) : m_expression(expression) {}
00051
00054 template<typename OtherDerived>
00055 EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
00056 { return internal::assign_selector<ExpressionType,OtherDerived,false>::run(m_expression,other.derived()); }
00057
00059 template<typename OtherDerived>
00060 EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
00061 {
00062 typedef SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
00063 SelfAdder tmp(m_expression);
00064 typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
00065 typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
00066 internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
00067 return m_expression;
00068 }
00069
00071 template<typename OtherDerived>
00072 EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
00073 {
00074 typedef SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
00075 SelfAdder tmp(m_expression);
00076 typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
00077 typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
00078 internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
00079 return m_expression;
00080 }
00081
00082 #ifndef EIGEN_PARSED_BY_DOXYGEN
00083 template<typename ProductDerived, typename Lhs, typename Rhs>
00084 EIGEN_STRONG_INLINE ExpressionType& operator+=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
00085 { other.derived().addTo(m_expression); return m_expression; }
00086
00087 template<typename ProductDerived, typename Lhs, typename Rhs>
00088 EIGEN_STRONG_INLINE ExpressionType& operator-=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
00089 { other.derived().subTo(m_expression); return m_expression; }
00090
00091 template<typename Lhs, typename Rhs, int NestingFlags>
00092 EIGEN_STRONG_INLINE ExpressionType& operator+=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
00093 { return m_expression.derived() += CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
00094
00095 template<typename Lhs, typename Rhs, int NestingFlags>
00096 EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
00097 { return m_expression.derived() -= CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
00098 #endif
00099
00100 protected:
00101 ExpressionType& m_expression;
00102 };
00103
00132 template<typename Derived>
00133 NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
00134 {
00135 return derived();
00136 }
00137
00138 }
00139
00140 #endif // EIGEN_NOALIAS_H