Eigen  5.0.1
 
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_STRIDE_H
12#define EIGEN_STRIDE_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
55template <int OuterStrideAtCompileTime_, int InnerStrideAtCompileTime_>
56class Stride {
57 public:
58 using Index = Eigen::Index;
59 enum { InnerStrideAtCompileTime = InnerStrideAtCompileTime_, OuterStrideAtCompileTime = OuterStrideAtCompileTime_ };
60
62 EIGEN_DEVICE_FUNC constexpr Stride() : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) {
63 eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);
64 }
65
67 EIGEN_DEVICE_FUNC constexpr Stride(Index outerStride, Index innerStride)
68 : m_outer(outerStride), m_inner(innerStride) {}
69
71 EIGEN_DEVICE_FUNC constexpr Stride(const Stride& other) = default;
72
74 EIGEN_DEVICE_FUNC constexpr 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 constexpr Index outer() const { return m_outer.value(); }
83 EIGEN_DEVICE_FUNC constexpr 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 using Base = Stride<0, Value>;
95
96 public:
97 EIGEN_DEVICE_FUNC constexpr InnerStride() = default;
98 EIGEN_DEVICE_FUNC constexpr 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 using Base = Stride<Value, 0>;
106
107 public:
108 EIGEN_DEVICE_FUNC constexpr OuterStride() = default;
109 EIGEN_DEVICE_FUNC constexpr 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
constexpr Stride & operator=(const Stride &other)
Definition Stride.h:74
constexpr Stride(Index outerStride, Index innerStride)
Definition Stride.h:67
constexpr Stride()
Definition Stride.h:62
constexpr Index outer() const
Definition Stride.h:81
constexpr Index inner() const
Definition Stride.h:83
constexpr Stride(const Stride &other)=default