Eigen  3.3.0
 
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
13namespace Eigen {
14
43template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime>
44class Stride
45{
46 public:
48 enum {
49 InnerStrideAtCompileTime = _InnerStrideAtCompileTime,
50 OuterStrideAtCompileTime = _OuterStrideAtCompileTime
51 };
52
54 EIGEN_DEVICE_FUNC
56 : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime)
57 {
58 eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);
59 }
60
62 EIGEN_DEVICE_FUNC
63 Stride(Index outerStride, Index innerStride)
64 : m_outer(outerStride), m_inner(innerStride)
65 {
66 eigen_assert(innerStride>=0 && outerStride>=0);
67 }
68
70 EIGEN_DEVICE_FUNC
71 Stride(const Stride& other)
72 : m_outer(other.outer()), m_inner(other.inner())
73 {}
74
76 EIGEN_DEVICE_FUNC
77 inline Index outer() const { return m_outer.value(); }
79 EIGEN_DEVICE_FUNC
80 inline Index inner() const { return m_inner.value(); }
81
82 protected:
83 internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
84 internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner;
85};
86
89template<int Value>
90class InnerStride : public Stride<0, Value>
91{
92 typedef Stride<0, Value> Base;
93 public:
94 EIGEN_DEVICE_FUNC InnerStride() : Base() {}
95 EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code
96};
97
100template<int Value>
101class OuterStride : public Stride<Value, 0>
102{
103 typedef Stride<Value, 0> Base;
104 public:
105 EIGEN_DEVICE_FUNC OuterStride() : Base() {}
106 EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code
107};
108
109} // end namespace Eigen
110
111#endif // EIGEN_STRIDE_H
Convenience specialization of Stride to specify only an inner stride See class Map for some examples.
Definition: Stride.h:91
Convenience specialization of Stride to specify only an outer stride See class Map for some examples.
Definition: Stride.h:102
Holds strides information for Map.
Definition: Stride.h:45
Stride(Index outerStride, Index innerStride)
Definition: Stride.h:63
Index inner() const
Definition: Stride.h:80
Eigen::Index Index
Definition: Stride.h:47
Stride(const Stride &other)
Definition: Stride.h:71
Index outer() const
Definition: Stride.h:77
Stride()
Definition: Stride.h:55
Namespace containing all symbols from the Eigen library.
Definition: Core:287
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
const int Dynamic
Definition: Constants.h:21