Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
NoAlias.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_NOALIAS_H
11 #define EIGEN_NOALIAS_H
12 
13 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
32 template<typename ExpressionType, template <typename> class StorageBase>
33 class NoAlias
34 {
35  public:
36  typedef typename ExpressionType::Scalar Scalar;
37 
38  EIGEN_DEVICE_FUNC
39  explicit NoAlias(ExpressionType& expression) : m_expression(expression) {}
40 
41  template<typename OtherDerived>
42  EIGEN_DEVICE_FUNC
43  EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
44  {
45  call_assignment_no_alias(m_expression, other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
46  return m_expression;
47  }
48 
49  template<typename OtherDerived>
50  EIGEN_DEVICE_FUNC
51  EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
52  {
53  call_assignment_no_alias(m_expression, other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
54  return m_expression;
55  }
56 
57  template<typename OtherDerived>
58  EIGEN_DEVICE_FUNC
59  EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
60  {
61  call_assignment_no_alias(m_expression, other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
62  return m_expression;
63  }
64 
65  EIGEN_DEVICE_FUNC
66  ExpressionType& expression() const
67  {
68  return m_expression;
69  }
70 
71  protected:
72  ExpressionType& m_expression;
73 };
74 
103 template<typename Derived>
105 {
106  return NoAlias<Derived, Eigen::MatrixBase >(derived());
107 }
108 
109 } // end namespace Eigen
110 
111 #endif // EIGEN_NOALIAS_H
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:104
Pseudo expression providing an operator = assuming no aliasing.
Definition: NoAlias.h:34
Namespace containing all symbols from the Eigen library.
Definition: Core:139