Eigen  3.4.1 (git rev 28ded8800c26864e537852658428ab44c8399e87)
 
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
51template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime>
52class Stride
53{
54 public:
56 enum {
57 InnerStrideAtCompileTime = _InnerStrideAtCompileTime,
58 OuterStrideAtCompileTime = _OuterStrideAtCompileTime
59 };
60
62 EIGEN_DEVICE_FUNC
64 : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime)
65 {
66 // FIXME: for Eigen 4 we should use DynamicIndex instead of Dynamic.
67 // FIXME: for Eigen 4 we should also unify this API with fix<>
68 eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);
69 }
70
72 EIGEN_DEVICE_FUNC
73 Stride(Index outerStride, Index innerStride)
74 : m_outer(outerStride), m_inner(innerStride)
75 {
76 }
77
79 EIGEN_DEVICE_FUNC
80 Stride(const Stride& other)
81 : m_outer(other.outer()), m_inner(other.inner())
82 {}
83
85 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
86 inline Index outer() const { return m_outer.value(); }
88 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
89 inline Index inner() const { return m_inner.value(); }
90
91 protected:
92 internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
93 internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner;
94};
95
98template<int Value>
99class InnerStride : public Stride<0, Value>
100{
101 typedef Stride<0, Value> Base;
102 public:
103 EIGEN_DEVICE_FUNC InnerStride() : Base() {}
104 EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code
105};
106
109template<int Value>
110class OuterStride : public Stride<Value, 0>
111{
112 typedef Stride<Value, 0> Base;
113 public:
114 EIGEN_DEVICE_FUNC OuterStride() : Base() {}
115 EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code
116};
117
118} // end namespace Eigen
119
120#endif // EIGEN_STRIDE_H
Stride(Index outerStride, Index innerStride)
Definition Stride.h:73
Stride(const Stride &other)
Definition Stride.h:80
Stride()
Definition Stride.h:63
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:74
const int Dynamic
Definition Constants.h:22