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 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_NOALIAS_H
00026 #define EIGEN_NOALIAS_H
00027 
00043 template<typename ExpressionType, template <typename> class StorageBase>
00044 class NoAlias
00045 {
00046     typedef typename ExpressionType::Scalar Scalar;
00047   public:
00048     NoAlias(ExpressionType& expression) : m_expression(expression) {}
00049 
00052     template<typename OtherDerived>
00053     EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
00054     { return internal::assign_selector<ExpressionType,OtherDerived,false>::run(m_expression,other.derived()); }
00055 
00057     template<typename OtherDerived>
00058     EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
00059     {
00060       typedef SelfCwiseBinaryOp<internal::scalar_sum_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
00061       SelfAdder tmp(m_expression);
00062       typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
00063       typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
00064       internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
00065       return m_expression;
00066     }
00067 
00069     template<typename OtherDerived>
00070     EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
00071     {
00072       typedef SelfCwiseBinaryOp<internal::scalar_difference_op<Scalar>, ExpressionType, OtherDerived> SelfAdder;
00073       SelfAdder tmp(m_expression);
00074       typedef typename internal::nested<OtherDerived>::type OtherDerivedNested;
00075       typedef typename internal::remove_all<OtherDerivedNested>::type _OtherDerivedNested;
00076       internal::assign_selector<SelfAdder,_OtherDerivedNested,false>::run(tmp,OtherDerivedNested(other.derived()));
00077       return m_expression;
00078     }
00079 
00080 #ifndef EIGEN_PARSED_BY_DOXYGEN
00081     template<typename ProductDerived, typename Lhs, typename Rhs>
00082     EIGEN_STRONG_INLINE ExpressionType& operator+=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
00083     { other.derived().addTo(m_expression); return m_expression; }
00084 
00085     template<typename ProductDerived, typename Lhs, typename Rhs>
00086     EIGEN_STRONG_INLINE ExpressionType& operator-=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
00087     { other.derived().subTo(m_expression); return m_expression; }
00088 
00089     template<typename Lhs, typename Rhs, int NestingFlags>
00090     EIGEN_STRONG_INLINE ExpressionType& operator+=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
00091     { return m_expression.derived() += CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
00092 
00093     template<typename Lhs, typename Rhs, int NestingFlags>
00094     EIGEN_STRONG_INLINE ExpressionType& operator-=(const CoeffBasedProduct<Lhs,Rhs,NestingFlags>& other)
00095     { return m_expression.derived() -= CoeffBasedProduct<Lhs,Rhs,NestByRefBit>(other.lhs(), other.rhs()); }
00096 #endif
00097 
00098   protected:
00099     ExpressionType& m_expression;
00100 };
00101 
00130 template<typename Derived>
00131 NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
00132 {
00133   return derived();
00134 }
00135 
00136 #endif // EIGEN_NOALIAS_H


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