WPILibC++ 2023.4.3
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
13namespace Eigen {
14
15/** \class Stride
16 * \ingroup Core_Module
17 *
18 * \brief Holds strides information for Map
19 *
20 * This class holds the strides information for mapping arrays with strides with class Map.
21 *
22 * It holds two values: the inner stride and the outer stride.
23 *
24 * The inner stride is the pointer increment between two consecutive entries within a given row of a
25 * row-major matrix or within a given column of a column-major matrix.
26 *
27 * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or
28 * between two consecutive columns of a column-major matrix.
29 *
30 * These two values can be passed either at compile-time as template parameters, or at runtime as
31 * arguments to the constructor.
32 *
33 * Indeed, this class takes two template parameters:
34 * \tparam _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime.
35 * \tparam _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime.
36 *
37 * Here is an example:
38 * \include Map_general_stride.cpp
39 * Output: \verbinclude Map_general_stride.out
40 *
41 * Both strides can be negative, however, a negative stride of -1 cannot be specified at compiletime
42 * because of the ambiguity with Dynamic which is defined to -1 (historically, negative strides were
43 * not allowed).
44 *
45 * \sa class InnerStride, class OuterStride, \ref TopicStorageOrders
46 */
47template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime>
48class Stride
49{
50 public:
51 typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
52 enum {
53 InnerStrideAtCompileTime = _InnerStrideAtCompileTime,
54 OuterStrideAtCompileTime = _OuterStrideAtCompileTime
55 };
56
57 /** Default constructor, for use when strides are fixed at compile time */
61 {
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
67 /** Constructor allowing to pass the strides at runtime */
69 Stride(Index outerStride, Index innerStride)
70 : m_outer(outerStride), m_inner(innerStride)
71 {
72 }
73
74 /** Copy constructor */
76 Stride(const Stride& other)
77 : m_outer(other.outer()), m_inner(other.inner())
78 {}
79
80 /** \returns the outer stride */
82 inline Index outer() const { return m_outer.value(); }
83 /** \returns the inner stride */
85 inline Index inner() const { return m_inner.value(); }
86
87 protected:
90};
91
92/** \brief Convenience specialization of Stride to specify only an inner stride
93 * See class Map for some examples */
94template<int Value>
95class InnerStride : public Stride<0, Value>
96{
97 typedef Stride<0, Value> Base;
98 public:
100 EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code
101};
102
103/** \brief Convenience specialization of Stride to specify only an outer stride
104 * See class Map for some examples */
105template<int Value>
106class OuterStride : public Stride<Value, 0>
107{
108 typedef Stride<Value, 0> Base;
109 public:
111 EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code
112};
113
114} // end namespace Eigen
115
116#endif // EIGEN_STRIDE_H
#define EIGEN_CONSTEXPR
Definition: Macros.h:797
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define eigen_assert(x)
Definition: Macros.h:1047
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:96
EIGEN_DEVICE_FUNC InnerStride(Index v)
Definition: Stride.h:100
EIGEN_DEVICE_FUNC InnerStride()
Definition: Stride.h:99
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:107
EIGEN_DEVICE_FUNC OuterStride()
Definition: Stride.h:110
EIGEN_DEVICE_FUNC OuterStride(Index v)
Definition: Stride.h:111
Holds strides information for Map.
Definition: Stride.h:49
EIGEN_DEVICE_FUNC Stride(const Stride &other)
Copy constructor.
Definition: Stride.h:76
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index inner() const
Definition: Stride.h:85
internal::variable_if_dynamic< Index, OuterStrideAtCompileTime > m_outer
Definition: Stride.h:88
@ InnerStrideAtCompileTime
Definition: Stride.h:53
@ OuterStrideAtCompileTime
Definition: Stride.h:54
internal::variable_if_dynamic< Index, InnerStrideAtCompileTime > m_inner
Definition: Stride.h:89
EIGEN_DEVICE_FUNC Stride()
Default constructor, for use when strides are fixed at compile time.
Definition: Stride.h:59
Eigen::Index Index
Definition: Stride.h:51
EIGEN_DEVICE_FUNC Stride(Index outerStride, Index innerStride)
Constructor allowing to pass the strides at runtime.
Definition: Stride.h:69
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outer() const
Definition: Stride.h:82
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:135
Namespace containing all symbols from the Eigen library.
Definition: MatrixExponential.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition: Constants.h:22