NoAlias.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) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_NOALIAS_H
00011 #define EIGEN_NOALIAS_H
00012 
00013 namespace Eigen {
00014 
00030 template<typename ExpressionType, template <typename> class StorageBase>
00031 class NoAlias
00032 {
00033     typedef typename ExpressionType::Scalar Scalar;
00034   public:
00035     NoAlias(ExpressionType& expression) : m_expression(expression) {}
00036 
00039     template<typename OtherDerived>
00040     EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
00041     { return internal::assign_selector<ExpressionType,OtherDerived,false>::run(m_expression,other.derived()); }
00042 
00044     template<typename OtherDerived>
00045     EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
00046     {
00047       typedef SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
00048       SelfAdder tmp(m_expression);
00049       typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
00050       typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
00051       internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
00052       return m_expression;
00053     }
00054 
00056     template<typename OtherDerived>
00057     EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
00058     {
00059       typedef SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
00060       SelfAdder tmp(m_expression);
00061       typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
00062       typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
00063       internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
00064       return m_expression;
00065     }
00066 
00067 #ifndef EIGEN_PARSED_BY_DOXYGEN
00068     template<typename ProductDerived, typename Lhs, typename Rhs>
00069     EIGEN_STRONG_INLINE ExpressionType& operator+=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
00070     { other.derived().addTo(m_expression); return m_expression; }
00071 
00072     template<typename ProductDerived, typename Lhs, typename Rhs>
00073     EIGEN_STRONG_INLINE ExpressionType& operator-=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
00074     { other.derived().subTo(m_expression); return m_expression; }
00075 
00076     template<typename Lhs, typename Rhs, int NestingFlags>
00077     EIGEN_STRONG_INLINE ExpressionType& operator+=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
00078     { return m_expression.derived() += CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
00079 
00080     template<typename Lhs, typename Rhs, int NestingFlags>
00081     EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
00082     { return m_expression.derived() -= CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
00083 #endif
00084 
00085   protected:
00086     ExpressionType& m_expression;
00087 };
00088 
00117 template<typename Derived>
00118 NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
00119 {
00120   return derived();
00121 }
00122 
00123 } // end namespace Eigen
00124 
00125 #endif // EIGEN_NOALIAS_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:11:18