Stride.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) 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 
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<>
71  }
72 
75  Stride(Index outerStride, Index innerStride)
76  : m_outer(outerStride), m_inner(innerStride)
77  {
78  }
79 
82  Stride(const Stride& other)
83  : m_outer(other.outer()), m_inner(other.inner())
84  {}
85 
88  inline Index outer() const { return m_outer.value(); }
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 {
104  public:
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 {
115  public:
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
Array< int, Dynamic, 1 > v
#define EIGEN_CONSTEXPR
Definition: Macros.h:747
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define eigen_assert(x)
Definition: Macros.h:902
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:102
InnerStride(Index v)
Definition: Stride.h:106
Stride< 0, Value > Base
Definition: Stride.h:103
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:113
Stride< Value, 0 > Base
Definition: Stride.h:114
OuterStride(Index v)
Definition: Stride.h:117
Holds strides information for Map.
Definition: Stride.h:55
EIGEN_CONSTEXPR Index inner() const
Definition: Stride.h:91
@ InnerStrideAtCompileTime
Definition: Stride.h:59
@ OuterStrideAtCompileTime
Definition: Stride.h:60
Stride(const Stride &other)
Definition: Stride.h:82
EIGEN_CONSTEXPR Index outer() const
Definition: Stride.h:88
internal::variable_if_dynamic< Index, InnerStrideAtCompileTime > m_inner
Definition: Stride.h:95
Eigen::Index Index
Definition: Stride.h:57
internal::variable_if_dynamic< Index, OuterStrideAtCompileTime > m_outer
Definition: Stride.h:94
Stride(Index outerStride, Index innerStride)
Definition: Stride.h:75
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Dynamic
Definition: Constants.h:24