Eigen  3.4.90 (git rev 9589cc4e7fd8e4538bedef80dd36c7738977a8be)
 
Loading...
Searching...
No Matches
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
16namespace Eigen {
17
54template <int OuterStrideAtCompileTime_, int InnerStrideAtCompileTime_>
55class Stride {
56 public:
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 EIGEN_CONSTEXPR inline Index outer() const { return m_outer.value(); }
83 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline 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
92template <int Value>
93class 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
103template <int Value>
104class 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
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition ForwardDeclarations.h:156
Holds strides information for Map.
Definition ForwardDeclarations.h:152
Stride()
Definition Stride.h:61
Stride(Index outerStride, Index innerStride)
Definition Stride.h:68
Stride & operator=(const Stride &other)
Definition Stride.h:74
Stride(const Stride &other)
Definition Stride.h:71
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25