Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
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 <[email protected]>
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// IWYU pragma: private
14#include "./InternalHeaderCheck.h"
15
16namespace Eigen {
17
31namespace internal {
32template <typename ExpressionType>
33struct traits<ForceAlignedAccess<ExpressionType>> : public traits<ExpressionType> {};
34} // namespace internal
35
36template <typename ExpressionType>
37class ForceAlignedAccess : public internal::dense_xpr_base<ForceAlignedAccess<ExpressionType>>::type {
38 public:
39 typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
40 EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
41
42 EIGEN_DEVICE_FUNC explicit inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
43
44 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
45 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
46 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index outerStride() const EIGEN_NOEXCEPT {
47 return m_expression.outerStride();
48 }
49 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index innerStride() const EIGEN_NOEXCEPT {
50 return m_expression.innerStride();
51 }
52
53 EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const {
54 return m_expression.coeff(row, col);
55 }
56
57 EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col) {
58 return m_expression.const_cast_derived().coeffRef(row, col);
59 }
60
61 EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const { return m_expression.coeff(index); }
62
63 EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) { return m_expression.const_cast_derived().coeffRef(index); }
64
65 template <int LoadMode>
66 inline const PacketScalar packet(Index row, Index col) const {
67 return m_expression.template packet<Aligned>(row, col);
68 }
69
70 template <int LoadMode>
71 inline void writePacket(Index row, Index col, const PacketScalar& x) {
72 m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
73 }
74
75 template <int LoadMode>
76 inline const PacketScalar packet(Index index) const {
77 return m_expression.template packet<Aligned>(index);
78 }
79
80 template <int LoadMode>
81 inline void writePacket(Index index, const PacketScalar& x) {
82 m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
83 }
84
85 EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }
86
87 protected:
88 const ExpressionType& m_expression;
89
90 private:
91 ForceAlignedAccess& operator=(const ForceAlignedAccess&);
92};
93
97template <typename Derived>
99 return ForceAlignedAccess<Derived>(derived());
100}
101
105template <typename Derived>
106inline ForceAlignedAccess<Derived> MatrixBase<Derived>::forceAlignedAccess() {
107 return ForceAlignedAccess<Derived>(derived());
108}
109
113template <typename Derived>
114template <bool Enable>
115inline add_const_on_value_type_t<std::conditional_t<Enable, ForceAlignedAccess<Derived>, Derived&>>
117 return derived(); // FIXME This should not work but apparently is never used
118}
119
123template <typename Derived>
124template <bool Enable>
125inline std::conditional_t<Enable, ForceAlignedAccess<Derived>, Derived&> MatrixBase<Derived>::forceAlignedAccessIf() {
126 return derived(); // FIXME This should not work but apparently is never used
127}
128
129} // end namespace Eigen
130
131#endif // EIGEN_FORCEALIGNEDACCESS_H
Enforce aligned packet loads and stores regardless of what is requested.
Definition ForceAlignedAccess.h:37
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83