![]() |
Eigen
3.3.3
|
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 public: 00034 typedef typename ExpressionType::Scalar Scalar; 00035 00036 explicit NoAlias(ExpressionType& expression) : m_expression(expression) {} 00037 00038 template<typename OtherDerived> 00039 EIGEN_DEVICE_FUNC 00040 EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) 00041 { 00042 call_assignment_no_alias(m_expression, other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>()); 00043 return m_expression; 00044 } 00045 00046 template<typename OtherDerived> 00047 EIGEN_DEVICE_FUNC 00048 EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other) 00049 { 00050 call_assignment_no_alias(m_expression, other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>()); 00051 return m_expression; 00052 } 00053 00054 template<typename OtherDerived> 00055 EIGEN_DEVICE_FUNC 00056 EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other) 00057 { 00058 call_assignment_no_alias(m_expression, other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>()); 00059 return m_expression; 00060 } 00061 00062 EIGEN_DEVICE_FUNC 00063 ExpressionType& expression() const 00064 { 00065 return m_expression; 00066 } 00067 00068 protected: 00069 ExpressionType& m_expression; 00070 }; 00071 00100 template<typename Derived> 00101 NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias() 00102 { 00103 return NoAlias<Derived, Eigen::MatrixBase >(derived()); 00104 } 00105 00106 } // end namespace Eigen 00107 00108 #endif // EIGEN_NOALIAS_H