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     
00084     template<typename OtherDerived>
00085     ExpressionType& operator=(const ReturnByValue<OtherDerived>& func)
00086     { return m_expression = func; }
00087 #endif
00088 
00089     ExpressionType& expression() const
00090     {
00091       return m_expression;
00092     }
00093 
00094   protected:
00095     ExpressionType& m_expression;
00096 };
00097 
00126 template<typename Derived>
00127 NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
00128 {
00129   return derived();
00130 }
00131 
00132 } // end namespace Eigen
00133 
00134 #endif // EIGEN_NOALIAS_H


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:14