11#ifndef EIGEN_ARITHMETIC_SEQUENCE_H
12#define EIGEN_ARITHMETIC_SEQUENCE_H
15#include "./InternalHeaderCheck.h"
23struct cleanup_seq_incr {
24 using type =
typename cleanup_index_type<T, DynamicIndex>::type;
33template <
typename FirstType = Index,
typename SizeType = Index,
typename IncrType =
internal::FixedInt<1> >
36template <
typename FirstType,
typename SizeType,
typename IncrType>
38 typename internal::cleanup_index_type<SizeType>::type,
39 typename internal::cleanup_seq_incr<IncrType>::type>
40seqN(FirstType first, SizeType size, IncrType incr);
62template <
typename FirstType,
typename SizeType,
typename IncrType>
63class ArithmeticSequence {
65 constexpr ArithmeticSequence() =
default;
66 constexpr ArithmeticSequence(FirstType
first, SizeType
size) : m_first(
first), m_size(
size) {}
67 constexpr ArithmeticSequence(FirstType
first, SizeType
size, IncrType incr)
68 : m_first(
first), m_size(
size), m_incr(incr) {}
72 IncrAtCompileTime = internal::get_fixed_value<IncrType, DynamicIndex>::value
76 constexpr Index
size()
const {
return m_size; }
79 constexpr Index
first()
const {
return m_first; }
82 constexpr Index
operator[](Index i)
const {
return m_first + i * m_incr; }
84 constexpr const FirstType& firstObject()
const {
return m_first; }
85 constexpr const SizeType& sizeObject()
const {
return m_size; }
86 constexpr const IncrType& incrObject()
const {
return m_incr; }
94 constexpr auto reverse()
const {
return seqN(m_first + (m_size +
fix<-1>()) * m_incr, m_size, -m_incr); }
100template <
typename FirstType,
typename SizeType,
typename IncrType>
102 typename internal::cleanup_index_type<SizeType>::type,
103 typename internal::cleanup_seq_incr<IncrType>::type>
104seqN(FirstType first, SizeType size, IncrType incr) {
106 typename internal::cleanup_index_type<SizeType>::type,
107 typename internal::cleanup_seq_incr<IncrType>::type>(first, size, incr);
113template <
typename FirstType,
typename SizeType>
115 typename internal::cleanup_index_type<SizeType>::type>
116seqN(FirstType first, SizeType size) {
118 typename internal::cleanup_index_type<SizeType>::type>(first, size);
121#ifdef EIGEN_PARSED_BY_DOXYGEN
133template <
typename FirstType,
typename LastType,
typename IncrType>
134auto seq(FirstType f, LastType l, IncrType incr);
145template <
typename FirstType,
typename LastType>
146auto seq(FirstType f, LastType l);
150template <
typename FirstType,
typename LastType>
151auto seq(FirstType f, LastType l) {
152 return seqN(
typename internal::cleanup_index_type<FirstType>::type(f),
153 (
typename internal::cleanup_index_type<LastType>::type(l) -
154 typename internal::cleanup_index_type<FirstType>::type(f) +
fix<1>()));
157template <
typename FirstType,
typename LastType,
typename IncrType>
158auto seq(FirstType f, LastType l, IncrType incr) {
159 using CleanedIncrType =
typename internal::cleanup_seq_incr<IncrType>::type;
160 return seqN(
typename internal::cleanup_index_type<FirstType>::type(f),
161 (
typename internal::cleanup_index_type<LastType>::type(l) -
162 typename internal::cleanup_index_type<FirstType>::type(f) + CleanedIncrType(incr)) /
163 CleanedIncrType(incr),
164 CleanedIncrType(incr));
169namespace placeholders {
176template <
typename SizeType,
typename IncrType>
177auto lastN(SizeType size, IncrType incr) {
186template <
typename SizeType>
187auto lastN(SizeType size) {
220using Eigen::placeholders::lastN;
Definition ArithmeticSequence.h:63
constexpr Index size() const
Definition ArithmeticSequence.h:76
constexpr Index operator[](Index i) const
Definition ArithmeticSequence.h:82
constexpr Index first() const
Definition ArithmeticSequence.h:79
static constexpr const last_t last
Definition IndexedViewHelper.h:49
static constexpr Eigen::internal::all_t all
Definition IndexedViewHelper.h:86
static constexpr auto lastp1
Definition IndexedViewHelper.h:68
auto seq(FirstType f, LastType l, IncrType incr)
ArithmeticSequence< typename internal::cleanup_index_type< FirstType >::type, typename internal::cleanup_index_type< SizeType >::type, typename internal::cleanup_seq_incr< IncrType >::type > seqN(FirstType first, SizeType size, IncrType incr)
Definition ArithmeticSequence.h:104
auto lastN(SizeType size, IncrType incr)
Definition ArithmeticSequence.h:177