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 // 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 
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<>
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 
75  m_outer.setValue(other.outer());
76  m_inner.setValue(other.inner());
77  return *this;
78  }
79 
84 
85  protected:
88 };
89 
92 template <int Value>
93 class InnerStride : public Stride<0, Value> {
95 
96  public:
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> {
106 
107  public:
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
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define eigen_assert(x)
Definition: Macros.h:910
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:93
EIGEN_DEVICE_FUNC InnerStride(Index v)
Definition: Stride.h:98
Stride< 0, Value > Base
Definition: Stride.h:94
EIGEN_DEVICE_FUNC InnerStride()
Definition: Stride.h:97
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:104
Stride< Value, 0 > Base
Definition: Stride.h:105
EIGEN_DEVICE_FUNC OuterStride()
Definition: Stride.h:108
EIGEN_DEVICE_FUNC OuterStride(Index v)
Definition: Stride.h:109
Holds strides information for Map.
Definition: Stride.h:55
EIGEN_DEVICE_FUNC Stride(const Stride &other)
Definition: Stride.h:71
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outer() const
Definition: Stride.h:81
EIGEN_DEVICE_FUNC Stride & operator=(const Stride &other)
Definition: Stride.h:74
@ InnerStrideAtCompileTime
Definition: Stride.h:58
@ OuterStrideAtCompileTime
Definition: Stride.h:58
EIGEN_DEVICE_FUNC Stride()
Definition: Stride.h:61
internal::variable_if_dynamic< Index, InnerStrideAtCompileTime > m_inner
Definition: Stride.h:87
EIGEN_DEVICE_FUNC Stride(Index outerStride, Index innerStride)
Definition: Stride.h:68
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index inner() const
Definition: Stride.h:83
Eigen::Index Index
Definition: Stride.h:57
internal::variable_if_dynamic< Index, OuterStrideAtCompileTime > m_outer
Definition: Stride.h:86
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void setValue(T v) const
Definition: XprHelper.h:163
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:161
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25