Eigen  3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)
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 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
53 template<int OuterStrideAtCompileTime_, int InnerStrideAtCompileTime_>
54 class Stride
55 {
56  public:
57  typedef Eigen::Index Index;
58  enum {
59  InnerStrideAtCompileTime = InnerStrideAtCompileTime_,
60  OuterStrideAtCompileTime = OuterStrideAtCompileTime_
61  };
62 
64  EIGEN_DEVICE_FUNC
66  : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime)
67  {
68  // FIXME: for Eigen 4 we should use DynamicIndex instead of Dynamic.
69  // FIXME: for Eigen 4 we should also unify this API with fix<>
70  eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);
71  }
72 
74  EIGEN_DEVICE_FUNC
75  Stride(Index outerStride, Index innerStride)
76  : m_outer(outerStride), m_inner(innerStride)
77  {
78  }
79 
81  EIGEN_DEVICE_FUNC
82  Stride(const Stride& other)
83  : m_outer(other.outer()), m_inner(other.inner())
84  {}
85 
87  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
88  inline Index outer() const { return m_outer.value(); }
90  EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
91  inline Index inner() const { return m_inner.value(); }
92 
93  protected:
94  internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
95  internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner;
96 };
97 
100 template<int Value>
101 class InnerStride : public Stride<0, Value>
102 {
103  typedef Stride<0, Value> Base;
104  public:
105  EIGEN_DEVICE_FUNC InnerStride() : Base() {}
106  EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code
107 };
108 
111 template<int Value>
112 class OuterStride : public Stride<Value, 0>
113 {
114  typedef Stride<Value, 0> Base;
115  public:
116  EIGEN_DEVICE_FUNC OuterStride() : Base() {}
117  EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code
118 };
119 
120 } // end namespace Eigen
121 
122 #endif // EIGEN_STRIDE_H
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:102
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:113
Holds strides information for Map.
Definition: Stride.h:55
EIGEN_CONSTEXPR Index inner() const
Definition: Stride.h:91
Stride(const Stride &other)
Definition: Stride.h:82
EIGEN_CONSTEXPR Index outer() const
Definition: Stride.h:88
Stride()
Definition: Stride.h:65
Eigen::Index Index
Definition: Stride.h:57
Stride(Index outerStride, Index innerStride)
Definition: Stride.h:75
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
const int Dynamic
Definition: Constants.h:24