Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
ForceAlignedAccess.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2010 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_FORCEALIGNEDACCESS_H
11 #define EIGEN_FORCEALIGNEDACCESS_H
12 
13 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
30 namespace internal {
31 template<typename ExpressionType>
32 struct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType>
33 {};
34 }
35 
36 template<typename ExpressionType> class ForceAlignedAccess
37  : public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type
38 {
39  public:
40 
41  typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
42  EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
43 
44  EIGEN_DEVICE_FUNC explicit inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
45 
46  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
47  inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
48  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
49  inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
50  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
51  inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
52  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
53  inline Index innerStride() const EIGEN_NOEXCEPT { return m_expression.innerStride(); }
54 
55  EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const
56  {
57  return m_expression.coeff(row, col);
58  }
59 
60  EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col)
61  {
62  return m_expression.const_cast_derived().coeffRef(row, col);
63  }
64 
65  EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const
66  {
67  return m_expression.coeff(index);
68  }
69 
70  EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index)
71  {
72  return m_expression.const_cast_derived().coeffRef(index);
73  }
74 
75  template<int LoadMode>
76  inline const PacketScalar packet(Index row, Index col) const
77  {
78  return m_expression.template packet<Aligned>(row, col);
79  }
80 
81  template<int LoadMode>
82  inline void writePacket(Index row, Index col, const PacketScalar& x)
83  {
84  m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
85  }
86 
87  template<int LoadMode>
88  inline const PacketScalar packet(Index index) const
89  {
90  return m_expression.template packet<Aligned>(index);
91  }
92 
93  template<int LoadMode>
94  inline void writePacket(Index index, const PacketScalar& x)
95  {
96  m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
97  }
98 
99  EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }
100 
101  protected:
102  const ExpressionType& m_expression;
103 
104  private:
105  ForceAlignedAccess& operator=(const ForceAlignedAccess&);
106 };
107 
111 template<typename Derived>
112 inline const ForceAlignedAccess<Derived>
114 {
115  return ForceAlignedAccess<Derived>(derived());
116 }
117 
121 template<typename Derived>
122 inline ForceAlignedAccess<Derived>
124 {
125  return ForceAlignedAccess<Derived>(derived());
126 }
127 
131 template<typename Derived>
132 template<bool Enable>
133 inline add_const_on_value_type_t<std::conditional_t<Enable,ForceAlignedAccess<Derived>,Derived&>>
135 {
136  return derived(); // FIXME This should not work but apparently is never used
137 }
138 
142 template<typename Derived>
143 template<bool Enable>
144 inline std::conditional_t<Enable,ForceAlignedAccess<Derived>,Derived&>
146 {
147  return derived(); // FIXME This should not work but apparently is never used
148 }
149 
150 } // end namespace Eigen
151 
152 #endif // EIGEN_FORCEALIGNEDACCESS_H
Enforce aligned packet loads and stores regardless of what is requested.
Definition: ForceAlignedAccess.h:38
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const Derived & forceAlignedAccess() const
Definition: MatrixBase.h:301
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59