NoAlias.h
Go to the documentation of this file.
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 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
33 template <typename ExpressionType, template <typename> class StorageBase>
34 class NoAlias {
35  public:
36  typedef typename ExpressionType::Scalar Scalar;
37 
39 
40  template <typename OtherDerived>
41  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) {
42  call_assignment_no_alias(m_expression, other.derived(),
44  return m_expression;
45  }
46 
47  template <typename OtherDerived>
48  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other) {
49  call_assignment_no_alias(m_expression, other.derived(),
51  return m_expression;
52  }
53 
54  template <typename OtherDerived>
55  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other) {
56  call_assignment_no_alias(m_expression, other.derived(),
58  return m_expression;
59  }
60 
61  EIGEN_DEVICE_FUNC ExpressionType& expression() const { return m_expression; }
62 
63  protected:
64  ExpressionType& m_expression;
65 };
66 
95 template <typename Derived>
97  return NoAlias<Derived, Eigen::MatrixBase>(derived());
98 }
99 
100 } // end namespace Eigen
101 
102 #endif // EIGEN_NOALIAS_H
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
SCALAR Scalar
Definition: bench_gemm.cpp:45
NoAlias< Derived, Eigen::MatrixBase > EIGEN_DEVICE_FUNC noalias()
Definition: NoAlias.h:96
Pseudo expression providing an operator = assuming no aliasing.
Definition: NoAlias.h:34
ExpressionType::Scalar Scalar
Definition: NoAlias.h:36
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType & operator=(const StorageBase< OtherDerived > &other)
Definition: NoAlias.h:41
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType & operator+=(const StorageBase< OtherDerived > &other)
Definition: NoAlias.h:48
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType & operator-=(const StorageBase< OtherDerived > &other)
Definition: NoAlias.h:55
EIGEN_DEVICE_FUNC ExpressionType & expression() const
Definition: NoAlias.h:61
ExpressionType & m_expression
Definition: NoAlias.h:64
EIGEN_DEVICE_FUNC NoAlias(ExpressionType &expression)
Definition: NoAlias.h:38
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:812
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Template functor for scalar/packet assignment with addition.
Definition: AssignmentFunctors.h:52
Template functor for scalar/packet assignment.
Definition: AssignmentFunctors.h:25
Template functor for scalar/packet assignment with subtraction.
Definition: AssignmentFunctors.h:73