$darkmode
Eigen  5.0.1-dev
Stride.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
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_STRIDE_H
11 #define EIGEN_STRIDE_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
54 template <int OuterStrideAtCompileTime_, int InnerStrideAtCompileTime_>
55 class Stride {
56  public:
57  typedef Eigen::Index Index;
58  enum { InnerStrideAtCompileTime = InnerStrideAtCompileTime_, OuterStrideAtCompileTime = OuterStrideAtCompileTime_ };
59 
61  EIGEN_DEVICE_FUNC Stride() : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) {
62  // FIXME: for Eigen 4 we should use DynamicIndex instead of Dynamic.
63  // FIXME: for Eigen 4 we should also unify this API with fix<>
64  eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);
65  }
66 
68  EIGEN_DEVICE_FUNC Stride(Index outerStride, Index innerStride) : m_outer(outerStride), m_inner(innerStride) {}
69 
71  EIGEN_DEVICE_FUNC Stride(const Stride& other) : m_outer(other.outer()), m_inner(other.inner()) {}
72 
74  EIGEN_DEVICE_FUNC Stride& operator=(const Stride& other) {
75  m_outer.setValue(other.outer());
76  m_inner.setValue(other.inner());
77  return *this;
78  }
79 
81  EIGEN_DEVICE_FUNC constexpr Index outer() const { return m_outer.value(); }
83  EIGEN_DEVICE_FUNC constexpr Index inner() const { return m_inner.value(); }
84 
85  protected:
86  internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
87  internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner;
88 };
89 
92 template <int Value>
93 class InnerStride : public Stride<0, Value> {
94  typedef Stride<0, Value> Base;
95 
96  public:
97  EIGEN_DEVICE_FUNC InnerStride() : Base() {}
98  EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code
99 };
100 
103 template <int Value>
104 class OuterStride : public Stride<Value, 0> {
105  typedef Stride<Value, 0> Base;
106 
107  public:
108  EIGEN_DEVICE_FUNC OuterStride() : Base() {}
109  EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v, 0) {} // FIXME making this explicit could break valid code
110 };
111 
112 } // end namespace Eigen
113 
114 #endif // EIGEN_STRIDE_H
Stride & operator=(const Stride &other)
Definition: Stride.h:74
Stride(const Stride &other)
Definition: Stride.h:71
Stride(Index outerStride, Index innerStride)
Definition: Stride.h:68
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Holds strides information for Map.
Definition: Stride.h:55
constexpr Index outer() const
Definition: Stride.h:81
Convenience specialization of Stride to specify only an inner stride See class Map for some examples...
Definition: Stride.h:93
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
constexpr Index inner() const
Definition: Stride.h:83
Eigen::Index Index
Definition: Stride.h:57
const int Dynamic
Definition: Constants.h:25
Stride()
Definition: Stride.h:61
Convenience specialization of Stride to specify only an outer stride See class Map for some examples...
Definition: Stride.h:104