$darkmode
Eigen  5.0.1-dev
IndexedViewHelper.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
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_INDEXED_VIEW_HELPER_H
11 #define EIGEN_INDEXED_VIEW_HELPER_H
12 
13 // IWYU pragma: private
14 #include "../InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 struct symbolic_last_tag {};
20 
21 struct all_t {};
22 
23 } // namespace internal
24 
25 namespace placeholders {
26 
27 typedef symbolic::SymbolExpr<internal::symbolic_last_tag> last_t;
28 
48 static constexpr const last_t last;
49 
50 typedef symbolic::AddExpr<symbolic::SymbolExpr<internal::symbolic_last_tag>,
51  symbolic::ValueExpr<Eigen::internal::FixedInt<1>>>
52  lastp1_t;
53 typedef Eigen::internal::all_t all_t;
54 
67 #ifdef EIGEN_PARSED_BY_DOXYGEN
68 static constexpr auto lastp1 = last + fix<1>;
69 #else
70 // Using a FixedExpr<1> expression is important here to make sure the compiler
71 // can fully optimize the computation starting indices with zero overhead.
72 static constexpr lastp1_t lastp1 = lastp1_t{};
73 #endif
74 
79 static constexpr lastp1_t end = lastp1;
80 
86 static constexpr Eigen::internal::all_t all;
87 
88 } // namespace placeholders
89 
90 namespace internal {
91 
92 // Evaluate a symbolic expression or constant given the "size" of an object, allowing
93 // any symbols like `last` to be evaluated. The default here assumes a dynamic constant.
94 template <typename Expr, int SizeAtCompileTime, typename EnableIf = void>
95 struct SymbolicExpressionEvaluator {
96  static constexpr Index ValueAtCompileTime = Undefined;
97  static Index eval(const Expr& expr, Index /*size*/) { return static_cast<Index>(expr); }
98 };
99 
100 // Symbolic expression with size known at compile-time.
101 template <typename Expr, int SizeAtCompileTime>
102 struct SymbolicExpressionEvaluator<Expr, SizeAtCompileTime, std::enable_if_t<symbolic::is_symbolic<Expr>::value>> {
103  static constexpr Index ValueAtCompileTime =
104  Expr::Derived::eval_at_compile_time(Eigen::placeholders::last = fix<SizeAtCompileTime - 1>);
105  static Index eval(const Expr& expr, Index /*size*/) {
106  return expr.eval(Eigen::placeholders::last = fix<SizeAtCompileTime - 1>);
107  }
108 };
109 
110 // Symbolic expression with dynamic size.
111 template <typename Expr>
112 struct SymbolicExpressionEvaluator<Expr, Dynamic, std::enable_if_t<symbolic::is_symbolic<Expr>::value>> {
113  static constexpr Index ValueAtCompileTime = Undefined;
114  static Index eval(const Expr& expr, Index size) { return expr.eval(Eigen::placeholders::last = size - 1); }
115 };
116 
117 // Fixed int.
118 template <int N, int SizeAtCompileTime>
119 struct SymbolicExpressionEvaluator<FixedInt<N>, SizeAtCompileTime, void> {
120  static constexpr Index ValueAtCompileTime = static_cast<Index>(N);
121  static Index eval(const FixedInt<N>& /*expr*/, Index /*size*/) { return ValueAtCompileTime; }
122 };
123 
124 //--------------------------------------------------------------------------------
125 // Handling of generic indices (e.g. array)
126 //--------------------------------------------------------------------------------
127 
128 // Potentially wrap indices in a type that is better-suited for IndexedView evaluation.
129 template <typename Indices, int NestedSizeAtCompileTime, typename EnableIf = void>
130 struct IndexedViewHelperIndicesWrapper {
131  using type = Indices;
132  static const type& CreateIndexSequence(const Indices& indices, Index /*nested_size*/) { return indices; }
133 };
134 
135 // Extract compile-time and runtime first, size, increments.
136 template <typename Indices, typename EnableIf = void>
137 struct IndexedViewHelper {
138  static constexpr Index FirstAtCompileTime = Undefined;
139  static constexpr Index SizeAtCompileTime = array_size<Indices>::value;
140  static constexpr Index IncrAtCompileTime = Undefined;
141 
142  static constexpr Index first(const Indices& indices) { return static_cast<Index>(indices[0]); }
143  static constexpr Index size(const Indices& indices) { return index_list_size(indices); }
144  static constexpr Index incr(const Indices& /*indices*/) { return Undefined; }
145 };
146 
147 //--------------------------------------------------------------------------------
148 // Handling of ArithmeticSequence
149 //--------------------------------------------------------------------------------
150 
151 template <Index FirstAtCompileTime_, Index SizeAtCompileTime_, Index IncrAtCompileTime_>
152 class ArithmeticSequenceRange {
153  public:
154  static constexpr Index FirstAtCompileTime = FirstAtCompileTime_;
155  static constexpr Index SizeAtCompileTime = SizeAtCompileTime_;
156  static constexpr Index IncrAtCompileTime = IncrAtCompileTime_;
157 
158  constexpr ArithmeticSequenceRange(Index first, Index size, Index incr) : first_{first}, size_{size}, incr_{incr} {}
159  constexpr Index operator[](Index i) const { return first() + i * incr(); }
160  constexpr Index first() const noexcept { return first_.value(); }
161  constexpr Index size() const noexcept { return size_.value(); }
162  constexpr Index incr() const noexcept { return incr_.value(); }
163 
164  private:
165  variable_if_dynamicindex<Index, int(FirstAtCompileTime)> first_;
166  variable_if_dynamic<Index, int(SizeAtCompileTime)> size_;
167  variable_if_dynamicindex<Index, int(IncrAtCompileTime)> incr_;
168 };
169 
170 template <typename FirstType, typename SizeType, typename IncrType, int NestedSizeAtCompileTime>
171 struct IndexedViewHelperIndicesWrapper<ArithmeticSequence<FirstType, SizeType, IncrType>, NestedSizeAtCompileTime,
172  void> {
173  static constexpr Index EvalFirstAtCompileTime =
174  SymbolicExpressionEvaluator<FirstType, NestedSizeAtCompileTime>::ValueAtCompileTime;
175  static constexpr Index EvalSizeAtCompileTime =
176  SymbolicExpressionEvaluator<SizeType, NestedSizeAtCompileTime>::ValueAtCompileTime;
177  static constexpr Index EvalIncrAtCompileTime =
178  SymbolicExpressionEvaluator<IncrType, NestedSizeAtCompileTime>::ValueAtCompileTime;
179 
180  static constexpr Index FirstAtCompileTime =
181  (int(EvalFirstAtCompileTime) == Undefined) ? Index(DynamicIndex) : EvalFirstAtCompileTime;
182  static constexpr Index SizeAtCompileTime =
183  (int(EvalSizeAtCompileTime) == Undefined) ? Index(Dynamic) : EvalSizeAtCompileTime;
184  static constexpr Index IncrAtCompileTime =
185  (int(EvalIncrAtCompileTime) == Undefined) ? Index(DynamicIndex) : EvalIncrAtCompileTime;
186 
187  using Indices = ArithmeticSequence<FirstType, SizeType, IncrType>;
188  using type = ArithmeticSequenceRange<FirstAtCompileTime, SizeAtCompileTime, IncrAtCompileTime>;
189 
190  static type CreateIndexSequence(const Indices& indices, Index nested_size) {
191  Index first =
192  SymbolicExpressionEvaluator<FirstType, NestedSizeAtCompileTime>::eval(indices.firstObject(), nested_size);
193  Index size =
194  SymbolicExpressionEvaluator<SizeType, NestedSizeAtCompileTime>::eval(indices.sizeObject(), nested_size);
195  Index incr =
196  SymbolicExpressionEvaluator<IncrType, NestedSizeAtCompileTime>::eval(indices.incrObject(), nested_size);
197  return type(first, size, incr);
198  }
199 };
200 
201 template <Index FirstAtCompileTime_, Index SizeAtCompileTime_, Index IncrAtCompileTime_>
202 struct IndexedViewHelper<ArithmeticSequenceRange<FirstAtCompileTime_, SizeAtCompileTime_, IncrAtCompileTime_>, void> {
203  public:
204  using Indices = ArithmeticSequenceRange<FirstAtCompileTime_, SizeAtCompileTime_, IncrAtCompileTime_>;
205  static constexpr Index FirstAtCompileTime = Indices::FirstAtCompileTime;
206  static constexpr Index SizeAtCompileTime = Indices::SizeAtCompileTime;
207  static constexpr Index IncrAtCompileTime = Indices::IncrAtCompileTime;
208  static Index first(const Indices& indices) { return indices.first(); }
209  static Index size(const Indices& indices) { return indices.size(); }
210  static Index incr(const Indices& indices) { return indices.incr(); }
211 };
212 
213 //--------------------------------------------------------------------------------
214 // Handling of a single index.
215 //--------------------------------------------------------------------------------
216 
217 template <Index ValueAtCompileTime>
218 class SingleRange {
219  public:
220  static constexpr Index FirstAtCompileTime = ValueAtCompileTime;
221  static constexpr Index SizeAtCompileTime = Index(1);
222  static constexpr Index IncrAtCompileTime = Index(1); // Needs to be 1 to be treated as block-like.
223 
224  constexpr SingleRange(Index v) noexcept : value_(v) {}
225  constexpr Index operator[](Index) const noexcept { return first(); }
226  constexpr Index first() const noexcept { return value_.value(); }
227  constexpr Index size() const noexcept { return SizeAtCompileTime; }
228  constexpr Index incr() const noexcept { return IncrAtCompileTime; }
229 
230  private:
231  variable_if_dynamicindex<Index, int(ValueAtCompileTime)> value_;
232 };
233 
234 template <typename T>
235 struct is_single_range : public std::false_type {};
236 
237 template <Index ValueAtCompileTime>
238 struct is_single_range<SingleRange<ValueAtCompileTime>> : public std::true_type {};
239 
240 template <typename SingleIndex, int NestedSizeAtCompileTime>
241 struct IndexedViewHelperIndicesWrapper<
242  SingleIndex, NestedSizeAtCompileTime,
243  std::enable_if_t<std::is_integral<SingleIndex>::value || symbolic::is_symbolic<SingleIndex>::value>> {
244  static constexpr Index EvalValueAtCompileTime =
245  SymbolicExpressionEvaluator<SingleIndex, NestedSizeAtCompileTime>::ValueAtCompileTime;
246  static constexpr Index ValueAtCompileTime =
247  (int(EvalValueAtCompileTime) == Undefined) ? Index(DynamicIndex) : EvalValueAtCompileTime;
248  using type = SingleRange<ValueAtCompileTime>;
249  static type CreateIndexSequence(const SingleIndex& index, Index nested_size) {
250  return type(SymbolicExpressionEvaluator<SingleIndex, NestedSizeAtCompileTime>::eval(index, nested_size));
251  }
252 };
253 
254 template <int N, int NestedSizeAtCompileTime>
255 struct IndexedViewHelperIndicesWrapper<FixedInt<N>, NestedSizeAtCompileTime, void> {
256  using type = SingleRange<Index(N)>;
257  static type CreateIndexSequence(const FixedInt<N>& /*index*/) { return type(Index(N)); }
258 };
259 
260 template <Index ValueAtCompileTime>
261 struct IndexedViewHelper<SingleRange<ValueAtCompileTime>, void> {
262  using Indices = SingleRange<ValueAtCompileTime>;
263  static constexpr Index FirstAtCompileTime = Indices::FirstAtCompileTime;
264  static constexpr Index SizeAtCompileTime = Indices::SizeAtCompileTime;
265  static constexpr Index IncrAtCompileTime = Indices::IncrAtCompileTime;
266 
267  static constexpr Index first(const Indices& indices) { return indices.first(); }
268  static constexpr Index size(const Indices& /*indices*/) { return SizeAtCompileTime; }
269  static constexpr Index incr(const Indices& /*indices*/) { return IncrAtCompileTime; }
270 };
271 
272 //--------------------------------------------------------------------------------
273 // Handling of all
274 //--------------------------------------------------------------------------------
275 
276 // Convert a symbolic 'all' into a usable range type
277 template <Index SizeAtCompileTime_>
278 class AllRange {
279  public:
280  static constexpr Index FirstAtCompileTime = Index(0);
281  static constexpr Index SizeAtCompileTime = SizeAtCompileTime_;
282  static constexpr Index IncrAtCompileTime = Index(1);
283  constexpr AllRange(Index size) : size_(size) {}
284  constexpr Index operator[](Index i) const noexcept { return i; }
285  constexpr Index first() const noexcept { return FirstAtCompileTime; }
286  constexpr Index size() const noexcept { return size_.value(); }
287  constexpr Index incr() const noexcept { return IncrAtCompileTime; }
288 
289  private:
290  variable_if_dynamic<Index, int(SizeAtCompileTime)> size_;
291 };
292 
293 template <int NestedSizeAtCompileTime>
294 struct IndexedViewHelperIndicesWrapper<all_t, NestedSizeAtCompileTime, void> {
295  using type = AllRange<Index(NestedSizeAtCompileTime)>;
296  static type CreateIndexSequence(const all_t& /*indices*/, Index nested_size) { return type(nested_size); }
297 };
298 
299 template <Index SizeAtCompileTime_>
300 struct IndexedViewHelper<AllRange<SizeAtCompileTime_>, void> {
301  using Indices = AllRange<SizeAtCompileTime_>;
302  static constexpr Index FirstAtCompileTime = Indices::FirstAtCompileTime;
303  static constexpr Index SizeAtCompileTime = Indices::SizeAtCompileTime;
304  static constexpr Index IncrAtCompileTime = Indices::IncrAtCompileTime;
305 
306  static Index first(const Indices& indices) { return indices.first(); }
307  static Index size(const Indices& indices) { return indices.size(); }
308  static Index incr(const Indices& indices) { return indices.incr(); }
309 };
310 
311 // this helper class assumes internal::valid_indexed_view_overload<RowIndices, ColIndices>::value == true
312 template <typename Derived, typename RowIndices, typename ColIndices, typename EnableIf = void>
313 struct IndexedViewSelector;
314 
315 template <typename Indices, int SizeAtCompileTime>
316 using IvcType = typename internal::IndexedViewHelperIndicesWrapper<Indices, SizeAtCompileTime>::type;
317 
318 template <int SizeAtCompileTime, typename Indices>
319 inline IvcType<Indices, SizeAtCompileTime> CreateIndexSequence(size_t size, const Indices& indices) {
320  return internal::IndexedViewHelperIndicesWrapper<Indices, SizeAtCompileTime>::CreateIndexSequence(indices, size);
321 }
322 
323 // Generic
324 template <typename Derived, typename RowIndices, typename ColIndices>
325 struct IndexedViewSelector<Derived, RowIndices, ColIndices,
326  std::enable_if_t<internal::traits<
327  IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
328  IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsIndexedView>> {
329  using ReturnType = IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
330  IvcType<ColIndices, Derived::ColsAtCompileTime>>;
331  using ConstReturnType = IndexedView<const Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
332  IvcType<ColIndices, Derived::ColsAtCompileTime>>;
333 
334  static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
335  return ReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices),
336  CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices));
337  }
338  static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
339  const ColIndices& colIndices) {
340  return ConstReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices),
341  CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices));
342  }
343 };
344 
345 // Block
346 template <typename Derived, typename RowIndices, typename ColIndices>
347 struct IndexedViewSelector<
348  Derived, RowIndices, ColIndices,
349  std::enable_if_t<internal::traits<IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
350  IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsBlock>> {
351  using ActualRowIndices = IvcType<RowIndices, Derived::RowsAtCompileTime>;
352  using ActualColIndices = IvcType<ColIndices, Derived::ColsAtCompileTime>;
353  using IndexedViewType = IndexedView<Derived, ActualRowIndices, ActualColIndices>;
354  using ConstIndexedViewType = IndexedView<const Derived, ActualRowIndices, ActualColIndices>;
355  using ReturnType = typename internal::traits<IndexedViewType>::BlockType;
356  using ConstReturnType = typename internal::traits<ConstIndexedViewType>::BlockType;
357  using RowHelper = internal::IndexedViewHelper<ActualRowIndices>;
358  using ColHelper = internal::IndexedViewHelper<ActualColIndices>;
359 
360  static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
361  auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
362  auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
363  return ReturnType(derived, RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices),
364  RowHelper::size(actualRowIndices), ColHelper::size(actualColIndices));
365  }
366  static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
367  const ColIndices& colIndices) {
368  auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
369  auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
370  return ConstReturnType(derived, RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices),
371  RowHelper::size(actualRowIndices), ColHelper::size(actualColIndices));
372  }
373 };
374 
375 // Scalar
376 template <typename Derived, typename RowIndices, typename ColIndices>
377 struct IndexedViewSelector<
378  Derived, RowIndices, ColIndices,
379  std::enable_if_t<internal::traits<IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
380  IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsScalar>> {
381  using ReturnType = typename DenseBase<Derived>::Scalar&;
382  using ConstReturnType = typename DenseBase<Derived>::CoeffReturnType;
383  using ActualRowIndices = IvcType<RowIndices, Derived::RowsAtCompileTime>;
384  using ActualColIndices = IvcType<ColIndices, Derived::ColsAtCompileTime>;
385  using RowHelper = internal::IndexedViewHelper<ActualRowIndices>;
386  using ColHelper = internal::IndexedViewHelper<ActualColIndices>;
387  static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
388  auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
389  auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
390  return derived(RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices));
391  }
392  static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
393  const ColIndices& colIndices) {
394  auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
395  auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
396  return derived(RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices));
397  }
398 };
399 
400 // this helper class assumes internal::is_valid_index_type<Indices>::value == false
401 template <typename Derived, typename Indices, typename EnableIf = void>
402 struct VectorIndexedViewSelector;
403 
404 // Generic
405 template <typename Derived, typename Indices>
406 struct VectorIndexedViewSelector<
407  Derived, Indices,
408  std::enable_if_t<!internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value &&
409  internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>::IncrAtCompileTime !=
410  1>> {
411  static constexpr bool IsRowMajor = DenseBase<Derived>::IsRowMajor;
412  using ZeroIndex = internal::SingleRange<Index(0)>;
413  using RowMajorReturnType = IndexedView<Derived, ZeroIndex, IvcType<Indices, Derived::SizeAtCompileTime>>;
414  using ConstRowMajorReturnType = IndexedView<const Derived, ZeroIndex, IvcType<Indices, Derived::SizeAtCompileTime>>;
415 
416  using ColMajorReturnType = IndexedView<Derived, IvcType<Indices, Derived::SizeAtCompileTime>, ZeroIndex>;
417  using ConstColMajorReturnType = IndexedView<const Derived, IvcType<Indices, Derived::SizeAtCompileTime>, ZeroIndex>;
418 
419  using ReturnType = typename internal::conditional<IsRowMajor, RowMajorReturnType, ColMajorReturnType>::type;
420  using ConstReturnType =
421  typename internal::conditional<IsRowMajor, ConstRowMajorReturnType, ConstColMajorReturnType>::type;
422 
423  template <bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor, bool> = true>
424  static inline RowMajorReturnType run(Derived& derived, const Indices& indices) {
425  return RowMajorReturnType(derived, ZeroIndex(0),
426  CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), indices));
427  }
428  template <bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor, bool> = true>
429  static inline ConstRowMajorReturnType run(const Derived& derived, const Indices& indices) {
430  return ConstRowMajorReturnType(derived, ZeroIndex(0),
431  CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), indices));
432  }
433  template <bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor, bool> = true>
434  static inline ColMajorReturnType run(Derived& derived, const Indices& indices) {
435  return ColMajorReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), indices),
436  ZeroIndex(0));
437  }
438  template <bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor, bool> = true>
439  static inline ConstColMajorReturnType run(const Derived& derived, const Indices& indices) {
440  return ConstColMajorReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), indices),
441  ZeroIndex(0));
442  }
443 };
444 
445 // Block
446 template <typename Derived, typename Indices>
447 struct VectorIndexedViewSelector<
448  Derived, Indices,
449  std::enable_if_t<!internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value &&
450  internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>::IncrAtCompileTime ==
451  1>> {
452  using Helper = internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>;
453  using ReturnType = VectorBlock<Derived, Helper::SizeAtCompileTime>;
454  using ConstReturnType = VectorBlock<const Derived, Helper::SizeAtCompileTime>;
455  static inline ReturnType run(Derived& derived, const Indices& indices) {
456  auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
457  return ReturnType(derived, Helper::first(actualIndices), Helper::size(actualIndices));
458  }
459  static inline ConstReturnType run(const Derived& derived, const Indices& indices) {
460  auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
461  return ConstReturnType(derived, Helper::first(actualIndices), Helper::size(actualIndices));
462  }
463 };
464 
465 // Symbolic
466 template <typename Derived, typename Indices>
467 struct VectorIndexedViewSelector<
468  Derived, Indices,
469  std::enable_if_t<internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value>> {
470  using ReturnType = typename DenseBase<Derived>::Scalar&;
471  using ConstReturnType = typename DenseBase<Derived>::CoeffReturnType;
472  using Helper = internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>;
473  static inline ReturnType run(Derived& derived, const Indices& indices) {
474  auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
475  return derived(Helper::first(actualIndices));
476  }
477  static inline ConstReturnType run(const Derived& derived, const Indices& indices) {
478  auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
479  return derived(Helper::first(actualIndices));
480  }
481 };
482 
483 } // end namespace internal
484 
485 } // end namespace Eigen
486 
487 #endif // EIGEN_INDEXED_VIEW_HELPER_H
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
static constexpr Eigen::internal::all_t all
Definition: IndexedViewHelper.h:86
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:62
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
const int DynamicIndex
Definition: Constants.h:30
Definition: BFloat16.h:231
static constexpr auto lastp1
Definition: IndexedViewHelper.h:68
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Undefined
Definition: Constants.h:34
Definition: DenseBase.h:166
const int Dynamic
Definition: Constants.h:25
static constexpr const last_t last
Definition: IndexedViewHelper.h:48
Definition: SymbolicIndex.h:320