ForceAlignedAccess.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-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;
43 
44  EIGEN_DEVICE_FUNC explicit inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
45 
47  inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
49  inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
51  inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
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 
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:
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
RowXpr row(Index i)
This is the const version of row(). *‍/.
ColXpr col(Index i)
This is the const version of col().
#define EIGEN_NOEXCEPT
Definition: Macros.h:1260
#define EIGEN_CONSTEXPR
Definition: Macros.h:747
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1168
Enforce aligned packet loads and stores regardless of what is requested.
const CoeffReturnType coeff(Index index) const
Scalar & coeffRef(Index index)
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
const PacketScalar packet(Index row, Index col) const
void writePacket(Index row, Index col, const PacketScalar &x)
void writePacket(Index index, const PacketScalar &x)
const CoeffReturnType coeff(Index row, Index col) const
const PacketScalar packet(Index index) const
EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
Scalar & coeffRef(Index row, Index col)
ForceAlignedAccess & operator=(const ForceAlignedAccess &)
EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
internal::dense_xpr_base< ForceAlignedAccess >::type Base
const ExpressionType & m_expression
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
const Derived & forceAlignedAccessIf() const
Definition: MatrixBase.h:312
const Derived & forceAlignedAccess() const
Definition: MatrixBase.h:310
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82