10 #ifndef EIGEN_INDEXED_VIEW_HELPER_H
11 #define EIGEN_INDEXED_VIEW_HELPER_H
14 #include "../InternalHeaderCheck.h"
25 namespace placeholders {
67 #ifdef EIGEN_PARSED_BY_DOXYGEN
94 template <
typename Expr,
int SizeAtCompileTime,
typename EnableIf =
void>
101 template <
typename Expr,
int SizeAtCompileTime>
111 template <
typename Expr>
118 template <
int N,
int SizeAtCompileTime>
129 template <
typename Indices,
int NestedSizeAtCompileTime,
typename EnableIf =
void>
136 template <
typename Indices,
typename EnableIf =
void>
142 static constexpr
Index first(
const Indices& indices) {
return static_cast<Index>(indices[0]); }
151 template <Index FirstAtCompileTime_, Index SizeAtCompileTime_, Index IncrAtCompileTime_>
170 template <
typename FirstType,
typename SizeType,
typename IncrType,
int NestedSizeAtCompileTime>
173 static constexpr
Index EvalFirstAtCompileTime =
175 static constexpr
Index EvalSizeAtCompileTime =
177 static constexpr
Index EvalIncrAtCompileTime =
180 static constexpr
Index FirstAtCompileTime =
182 static constexpr
Index SizeAtCompileTime =
184 static constexpr
Index IncrAtCompileTime =
201 template <Index FirstAtCompileTime_, Index SizeAtCompileTime_, Index IncrAtCompileTime_>
217 template <Index ValueAtCompileTime>
234 template <
typename T>
237 template <Index ValueAtCompileTime>
240 template <
typename SingleIndex,
int NestedSizeAtCompileTime>
242 SingleIndex, NestedSizeAtCompileTime,
243 std::enable_if_t<std::is_integral<SingleIndex>::value || symbolic::is_symbolic<SingleIndex>::value>> {
244 static constexpr
Index EvalValueAtCompileTime =
246 static constexpr
Index ValueAtCompileTime =
254 template <
int N,
int NestedSizeAtCompileTime>
260 template <Index ValueAtCompileTime>
277 template <Index SizeAtCompileTime_>
293 template <
int NestedSizeAtCompileTime>
299 template <Index SizeAtCompileTime_>
312 template <
typename Derived,
typename RowIndices,
typename ColIndices,
typename EnableIf =
void>
315 template <
typename Indices,
int SizeAtCompileTime>
318 template <
int SizeAtCompileTime,
typename Indices>
324 template <
typename Derived,
typename RowIndices,
typename ColIndices>
326 std::enable_if_t<internal::traits<
327 IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
328 IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsIndexedView>> {
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));
339 const ColIndices& colIndices) {
340 return ConstReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices),
341 CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices));
346 template <
typename Derived,
typename RowIndices,
typename ColIndices>
348 Derived, RowIndices, ColIndices,
349 std::enable_if_t<internal::traits<IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
350 IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsBlock>> {
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),
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),
376 template <
typename Derived,
typename RowIndices,
typename ColIndices>
378 Derived, RowIndices, ColIndices,
379 std::enable_if_t<internal::traits<IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
380 IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsScalar>> {
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));
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));
401 template <
typename Derived,
typename Indices,
typename EnableIf =
void>
405 template <
typename Derived,
typename Indices>
408 std::enable_if_t<!internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value &&
409 internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>::IncrAtCompileTime !=
423 template <
bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor,
bool> = true>
426 CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), indices));
428 template <
bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor,
bool> = true>
431 CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), indices));
433 template <
bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor,
bool> = true>
435 return ColMajorReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), indices),
438 template <
bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor,
bool> = true>
440 return ConstColMajorReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), indices),
446 template <
typename Derived,
typename Indices>
449 std::enable_if_t<!internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value &&
450 internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>::IncrAtCompileTime ==
456 auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
460 auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
466 template <
typename Derived,
typename Indices>
469 std::enable_if_t<internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value>> {
474 auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
475 return derived(Helper::first(actualIndices));
478 auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
479 return derived(Helper::first(actualIndices));
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Definition: ArithmeticSequence.h:62
constexpr const IncrType & incrObject() const
Definition: ArithmeticSequence.h:85
constexpr const FirstType & firstObject() const
Definition: ArithmeticSequence.h:83
constexpr const SizeType & sizeObject() const
Definition: ArithmeticSequence.h:84
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:44
Base::CoeffReturnType CoeffReturnType
Definition: DenseBase.h:92
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:62
Expression of a non-sequential sub-matrix defined by arbitrary sequences of row and column indices.
Definition: IndexedView.h:124
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:58
Definition: IndexedViewHelper.h:278
constexpr Index incr() const noexcept
Definition: IndexedViewHelper.h:287
constexpr AllRange(Index size)
Definition: IndexedViewHelper.h:283
constexpr Index operator[](Index i) const noexcept
Definition: IndexedViewHelper.h:284
static constexpr Index FirstAtCompileTime
Definition: IndexedViewHelper.h:280
constexpr Index first() const noexcept
Definition: IndexedViewHelper.h:285
static constexpr Index SizeAtCompileTime
Definition: IndexedViewHelper.h:281
constexpr Index size() const noexcept
Definition: IndexedViewHelper.h:286
variable_if_dynamic< Index, int(SizeAtCompileTime)> size_
Definition: IndexedViewHelper.h:290
static constexpr Index IncrAtCompileTime
Definition: IndexedViewHelper.h:282
Definition: IndexedViewHelper.h:152
constexpr Index first() const noexcept
Definition: IndexedViewHelper.h:160
constexpr Index operator[](Index i) const
Definition: IndexedViewHelper.h:159
static constexpr Index FirstAtCompileTime
Definition: IndexedViewHelper.h:154
constexpr Index incr() const noexcept
Definition: IndexedViewHelper.h:162
constexpr ArithmeticSequenceRange(Index first, Index size, Index incr)
Definition: IndexedViewHelper.h:158
variable_if_dynamic< Index, int(SizeAtCompileTime)> size_
Definition: IndexedViewHelper.h:166
variable_if_dynamicindex< Index, int(FirstAtCompileTime)> first_
Definition: IndexedViewHelper.h:165
static constexpr Index SizeAtCompileTime
Definition: IndexedViewHelper.h:155
static constexpr Index IncrAtCompileTime
Definition: IndexedViewHelper.h:156
variable_if_dynamicindex< Index, int(IncrAtCompileTime)> incr_
Definition: IndexedViewHelper.h:167
constexpr Index size() const noexcept
Definition: IndexedViewHelper.h:161
Definition: IntegralConstant.h:23
Definition: IndexedViewHelper.h:218
variable_if_dynamicindex< Index, int(ValueAtCompileTime)> value_
Definition: IndexedViewHelper.h:231
static constexpr Index IncrAtCompileTime
Definition: IndexedViewHelper.h:222
constexpr SingleRange(Index v) noexcept
Definition: IndexedViewHelper.h:224
static constexpr Index SizeAtCompileTime
Definition: IndexedViewHelper.h:221
constexpr Index operator[](Index) const noexcept
Definition: IndexedViewHelper.h:225
constexpr Index first() const noexcept
Definition: IndexedViewHelper.h:226
constexpr Index size() const noexcept
Definition: IndexedViewHelper.h:227
constexpr Index incr() const noexcept
Definition: IndexedViewHelper.h:228
static constexpr Index FirstAtCompileTime
Definition: IndexedViewHelper.h:220
Definition: XprHelper.h:154
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:161
Definition: XprHelper.h:183
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:189
Definition: SymbolicIndex.h:373
Definition: SymbolicIndex.h:320
Definition: SymbolicIndex.h:188
@ N
Definition: constructor.cpp:22
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
static constexpr Eigen::internal::all_t all
Definition: IndexedViewHelper.h:86
static constexpr const last_t last
Definition: IndexedViewHelper.h:48
static constexpr lastp1_t lastp1
Definition: IndexedViewHelper.h:72
IvcType< Indices, SizeAtCompileTime > CreateIndexSequence(size_t size, const Indices &indices)
Definition: IndexedViewHelper.h:319
typename internal::IndexedViewHelperIndicesWrapper< Indices, SizeAtCompileTime >::type IvcType
Definition: IndexedViewHelper.h:316
EIGEN_CONSTEXPR auto index_list_size(const T &x)
Definition: Meta.h:344
symbolic::AddExpr< symbolic::SymbolExpr< internal::symbolic_last_tag >, symbolic::ValueExpr< Eigen::internal::FixedInt< 1 > > > lastp1_t
Definition: IndexedViewHelper.h:52
symbolic::SymbolExpr< internal::symbolic_last_tag > last_t
Definition: IndexedViewHelper.h:27
Eigen::internal::all_t all_t
Definition: IndexedViewHelper.h:53
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
const int Undefined
Definition: Constants.h:34
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int DynamicIndex
Definition: Constants.h:30
const int Dynamic
Definition: Constants.h:25
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
unsigned SizeType
Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.
Definition: rapidjson.h:67
static type CreateIndexSequence(const Indices &indices, Index nested_size)
Definition: IndexedViewHelper.h:190
static type CreateIndexSequence(const FixedInt< N > &)
Definition: IndexedViewHelper.h:257
static type CreateIndexSequence(const SingleIndex &index, Index nested_size)
Definition: IndexedViewHelper.h:249
static type CreateIndexSequence(const all_t &, Index nested_size)
Definition: IndexedViewHelper.h:296
Definition: IndexedViewHelper.h:130
static const type & CreateIndexSequence(const Indices &indices, Index)
Definition: IndexedViewHelper.h:132
Indices type
Definition: IndexedViewHelper.h:131
static Index incr(const Indices &indices)
Definition: IndexedViewHelper.h:308
static Index first(const Indices &indices)
Definition: IndexedViewHelper.h:306
static Index size(const Indices &indices)
Definition: IndexedViewHelper.h:307
static Index first(const Indices &indices)
Definition: IndexedViewHelper.h:208
static Index size(const Indices &indices)
Definition: IndexedViewHelper.h:209
static Index incr(const Indices &indices)
Definition: IndexedViewHelper.h:210
static constexpr Index incr(const Indices &)
Definition: IndexedViewHelper.h:269
static constexpr Index first(const Indices &indices)
Definition: IndexedViewHelper.h:267
static constexpr Index size(const Indices &)
Definition: IndexedViewHelper.h:268
Definition: IndexedViewHelper.h:137
static constexpr Index SizeAtCompileTime
Definition: IndexedViewHelper.h:139
static constexpr Index incr(const Indices &)
Definition: IndexedViewHelper.h:144
static constexpr Index FirstAtCompileTime
Definition: IndexedViewHelper.h:138
static constexpr Index first(const Indices &indices)
Definition: IndexedViewHelper.h:142
static constexpr Index IncrAtCompileTime
Definition: IndexedViewHelper.h:140
static constexpr Index size(const Indices &indices)
Definition: IndexedViewHelper.h:143
static ConstReturnType run(const Derived &derived, const RowIndices &rowIndices, const ColIndices &colIndices)
Definition: IndexedViewHelper.h:366
IvcType< ColIndices, Derived::ColsAtCompileTime > ActualColIndices
Definition: IndexedViewHelper.h:352
typename internal::traits< ConstIndexedViewType >::BlockType ConstReturnType
Definition: IndexedViewHelper.h:356
static ReturnType run(Derived &derived, const RowIndices &rowIndices, const ColIndices &colIndices)
Definition: IndexedViewHelper.h:360
typename internal::traits< IndexedViewType >::BlockType ReturnType
Definition: IndexedViewHelper.h:355
IvcType< RowIndices, Derived::RowsAtCompileTime > ActualRowIndices
Definition: IndexedViewHelper.h:351
static ConstReturnType run(const Derived &derived, const RowIndices &rowIndices, const ColIndices &colIndices)
Definition: IndexedViewHelper.h:338
static ReturnType run(Derived &derived, const RowIndices &rowIndices, const ColIndices &colIndices)
Definition: IndexedViewHelper.h:334
typename DenseBase< Derived >::Scalar & ReturnType
Definition: IndexedViewHelper.h:381
IvcType< RowIndices, Derived::RowsAtCompileTime > ActualRowIndices
Definition: IndexedViewHelper.h:383
IvcType< ColIndices, Derived::ColsAtCompileTime > ActualColIndices
Definition: IndexedViewHelper.h:384
static ReturnType run(Derived &derived, const RowIndices &rowIndices, const ColIndices &colIndices)
Definition: IndexedViewHelper.h:387
typename DenseBase< Derived >::CoeffReturnType ConstReturnType
Definition: IndexedViewHelper.h:382
static ConstReturnType run(const Derived &derived, const RowIndices &rowIndices, const ColIndices &colIndices)
Definition: IndexedViewHelper.h:392
Definition: IndexedViewHelper.h:313
static Index eval(const Expr &expr, Index size)
Definition: IndexedViewHelper.h:114
static Index eval(const Expr &expr, Index)
Definition: IndexedViewHelper.h:105
static Index eval(const FixedInt< N > &, Index)
Definition: IndexedViewHelper.h:121
Definition: IndexedViewHelper.h:95
static Index eval(const Expr &expr, Index)
Definition: IndexedViewHelper.h:97
static constexpr Index ValueAtCompileTime
Definition: IndexedViewHelper.h:96
static ConstReturnType run(const Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:459
static ReturnType run(Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:455
typename internal::conditional< IsRowMajor, RowMajorReturnType, ColMajorReturnType >::type ReturnType
Definition: IndexedViewHelper.h:419
static ConstColMajorReturnType run(const Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:439
static ColMajorReturnType run(Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:434
static ConstRowMajorReturnType run(const Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:429
typename internal::conditional< IsRowMajor, ConstRowMajorReturnType, ConstColMajorReturnType >::type ConstReturnType
Definition: IndexedViewHelper.h:421
static RowMajorReturnType run(Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:424
typename DenseBase< Derived >::CoeffReturnType ConstReturnType
Definition: IndexedViewHelper.h:471
static ConstReturnType run(const Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:477
static ReturnType run(Derived &derived, const Indices &indices)
Definition: IndexedViewHelper.h:473
typename DenseBase< Derived >::Scalar & ReturnType
Definition: IndexedViewHelper.h:470
Definition: IndexedViewHelper.h:402
Definition: IndexedViewHelper.h:21
Definition: IndexedViewHelper.h:235
Definition: IndexedViewHelper.h:19
Definition: ForwardDeclarations.h:21