mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-21 17:19:36 +08:00
Refactor indexed view to appease MSVC 14.16.
This commit is contained in:
parent
5226566a14
commit
dcdb0233c1
@ -308,6 +308,178 @@ struct IndexedViewHelper<AllRange<SizeAtCompileTime_>, void> {
|
||||
static Index incr(const Indices& indices) { return indices.incr(); }
|
||||
};
|
||||
|
||||
// this helper class assumes internal::valid_indexed_view_overload<RowIndices, ColIndices>::value == true
|
||||
template <typename Derived, typename RowIndices, typename ColIndices, typename EnableIf = void>
|
||||
struct IndexedViewSelector;
|
||||
|
||||
template <typename Indices, int SizeAtCompileTime>
|
||||
using IvcType = typename internal::IndexedViewHelperIndicesWrapper<Indices, SizeAtCompileTime>::type;
|
||||
|
||||
template <int SizeAtCompileTime, typename Indices>
|
||||
inline IvcType<Indices, SizeAtCompileTime> CreateIndexSequence(size_t size, const Indices& indices) {
|
||||
return internal::IndexedViewHelperIndicesWrapper<Indices, SizeAtCompileTime>::CreateIndexSequence(indices, size);
|
||||
}
|
||||
|
||||
// Generic
|
||||
template <typename Derived, typename RowIndices, typename ColIndices>
|
||||
struct IndexedViewSelector<Derived, RowIndices, ColIndices,
|
||||
std::enable_if_t<internal::traits<
|
||||
IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
|
||||
IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsIndexedView>> {
|
||||
using ReturnType = IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
|
||||
IvcType<ColIndices, Derived::ColsAtCompileTime>>;
|
||||
using ConstReturnType = IndexedView<const Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
|
||||
IvcType<ColIndices, Derived::ColsAtCompileTime>>;
|
||||
|
||||
static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
return ReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices),
|
||||
CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) {
|
||||
return ConstReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices),
|
||||
CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// Block
|
||||
template <typename Derived, typename RowIndices, typename ColIndices>
|
||||
struct IndexedViewSelector<
|
||||
Derived, RowIndices, ColIndices,
|
||||
std::enable_if_t<internal::traits<IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
|
||||
IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsBlock>> {
|
||||
using ActualRowIndices = IvcType<RowIndices, Derived::RowsAtCompileTime>;
|
||||
using ActualColIndices = IvcType<ColIndices, Derived::ColsAtCompileTime>;
|
||||
using IndexedViewType = IndexedView<Derived, ActualRowIndices, ActualColIndices>;
|
||||
using ConstIndexedViewType = IndexedView<const Derived, ActualRowIndices, ActualColIndices>;
|
||||
using ReturnType = typename internal::traits<IndexedViewType>::BlockType;
|
||||
using ConstReturnType = typename internal::traits<ConstIndexedViewType>::BlockType;
|
||||
using RowHelper = internal::IndexedViewHelper<ActualRowIndices>;
|
||||
using ColHelper = internal::IndexedViewHelper<ActualColIndices>;
|
||||
|
||||
static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
|
||||
auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
|
||||
return ReturnType(derived, RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices),
|
||||
RowHelper::size(actualRowIndices), ColHelper::size(actualColIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) {
|
||||
auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
|
||||
auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
|
||||
return ConstReturnType(derived, RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices),
|
||||
RowHelper::size(actualRowIndices), ColHelper::size(actualColIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// Scalar
|
||||
template <typename Derived, typename RowIndices, typename ColIndices>
|
||||
struct IndexedViewSelector<
|
||||
Derived, RowIndices, ColIndices,
|
||||
std::enable_if_t<internal::traits<IndexedView<Derived, IvcType<RowIndices, Derived::RowsAtCompileTime>,
|
||||
IvcType<ColIndices, Derived::ColsAtCompileTime>>>::ReturnAsScalar>> {
|
||||
using ReturnType = typename DenseBase<Derived>::Scalar&;
|
||||
using ConstReturnType = typename DenseBase<Derived>::CoeffReturnType;
|
||||
using ActualRowIndices = IvcType<RowIndices, Derived::RowsAtCompileTime>;
|
||||
using ActualColIndices = IvcType<ColIndices, Derived::ColsAtCompileTime>;
|
||||
using RowHelper = internal::IndexedViewHelper<ActualRowIndices>;
|
||||
using ColHelper = internal::IndexedViewHelper<ActualColIndices>;
|
||||
static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
|
||||
auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
|
||||
return derived(RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) {
|
||||
auto actualRowIndices = CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), rowIndices);
|
||||
auto actualColIndices = CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), colIndices);
|
||||
return derived(RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// this helper class assumes internal::is_valid_index_type<Indices>::value == false
|
||||
template <typename Derived, typename Indices, typename EnableIf = void>
|
||||
struct VectorIndexedViewSelector;
|
||||
|
||||
// Generic
|
||||
template <typename Derived, typename Indices>
|
||||
struct VectorIndexedViewSelector<
|
||||
Derived, Indices,
|
||||
std::enable_if_t<!internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value &&
|
||||
internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>::IncrAtCompileTime !=
|
||||
1>> {
|
||||
static constexpr bool IsRowMajor = DenseBase<Derived>::IsRowMajor;
|
||||
using ZeroIndex = internal::SingleRange<Index(0)>;
|
||||
using RowMajorReturnType = IndexedView<Derived, ZeroIndex, IvcType<Indices, Derived::SizeAtCompileTime>>;
|
||||
using ConstRowMajorReturnType = IndexedView<const Derived, ZeroIndex, IvcType<Indices, Derived::SizeAtCompileTime>>;
|
||||
|
||||
using ColMajorReturnType = IndexedView<Derived, IvcType<Indices, Derived::SizeAtCompileTime>, ZeroIndex>;
|
||||
using ConstColMajorReturnType = IndexedView<const Derived, IvcType<Indices, Derived::SizeAtCompileTime>, ZeroIndex>;
|
||||
|
||||
using ReturnType = typename internal::conditional<IsRowMajor, RowMajorReturnType, ColMajorReturnType>::type;
|
||||
using ConstReturnType =
|
||||
typename internal::conditional<IsRowMajor, ConstRowMajorReturnType, ConstColMajorReturnType>::type;
|
||||
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor, bool> = true>
|
||||
static inline RowMajorReturnType run(Derived& derived, const Indices& indices) {
|
||||
return RowMajorReturnType(derived, ZeroIndex(0),
|
||||
CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), indices));
|
||||
}
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor, bool> = true>
|
||||
static inline ConstRowMajorReturnType run(const Derived& derived, const Indices& indices) {
|
||||
return ConstRowMajorReturnType(derived, ZeroIndex(0),
|
||||
CreateIndexSequence<Derived::ColsAtCompileTime>(derived.cols(), indices));
|
||||
}
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor, bool> = true>
|
||||
static inline ColMajorReturnType run(Derived& derived, const Indices& indices) {
|
||||
return ColMajorReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), indices),
|
||||
ZeroIndex(0));
|
||||
}
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor, bool> = true>
|
||||
static inline ConstColMajorReturnType run(const Derived& derived, const Indices& indices) {
|
||||
return ConstColMajorReturnType(derived, CreateIndexSequence<Derived::RowsAtCompileTime>(derived.rows(), indices),
|
||||
ZeroIndex(0));
|
||||
}
|
||||
};
|
||||
|
||||
// Block
|
||||
template <typename Derived, typename Indices>
|
||||
struct VectorIndexedViewSelector<
|
||||
Derived, Indices,
|
||||
std::enable_if_t<!internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value &&
|
||||
internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>::IncrAtCompileTime ==
|
||||
1>> {
|
||||
using Helper = internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>;
|
||||
using ReturnType = VectorBlock<Derived, Helper::SizeAtCompileTime>;
|
||||
using ConstReturnType = VectorBlock<const Derived, Helper::SizeAtCompileTime>;
|
||||
static inline ReturnType run(Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
|
||||
return ReturnType(derived, Helper::first(actualIndices), Helper::size(actualIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
|
||||
return ConstReturnType(derived, Helper::first(actualIndices), Helper::size(actualIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// Symbolic
|
||||
template <typename Derived, typename Indices>
|
||||
struct VectorIndexedViewSelector<
|
||||
Derived, Indices,
|
||||
std::enable_if_t<internal::is_single_range<IvcType<Indices, Derived::SizeAtCompileTime>>::value>> {
|
||||
using ReturnType = typename DenseBase<Derived>::Scalar&;
|
||||
using ConstReturnType = typename DenseBase<Derived>::CoeffReturnType;
|
||||
using Helper = internal::IndexedViewHelper<IvcType<Indices, Derived::SizeAtCompileTime>>;
|
||||
static inline ReturnType run(Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
|
||||
return derived(Helper::first(actualIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = CreateIndexSequence<Derived::SizeAtCompileTime>(derived.size(), indices);
|
||||
return derived(Helper::first(actualIndices));
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
} // end namespace Eigen
|
||||
|
@ -10,184 +10,6 @@
|
||||
#if !defined(EIGEN_PARSED_BY_DOXYGEN)
|
||||
|
||||
public:
|
||||
// define some aliases to ease readability
|
||||
|
||||
template <typename Indices>
|
||||
using IvcRowType = typename internal::IndexedViewHelperIndicesWrapper<Indices, RowsAtCompileTime>::type;
|
||||
|
||||
template <typename Indices>
|
||||
using IvcColType = typename internal::IndexedViewHelperIndicesWrapper<Indices, ColsAtCompileTime>::type;
|
||||
|
||||
template <typename Indices>
|
||||
using IvcSizeType = typename internal::IndexedViewHelperIndicesWrapper<Indices, SizeAtCompileTime>::type;
|
||||
|
||||
template <typename Indices>
|
||||
inline IvcRowType<Indices> ivcRow(const Indices& indices) const {
|
||||
return internal::IndexedViewHelperIndicesWrapper<Indices, RowsAtCompileTime>::CreateIndexSequence(indices,
|
||||
derived().rows());
|
||||
}
|
||||
|
||||
template <typename Indices>
|
||||
inline IvcColType<Indices> ivcCol(const Indices& indices) const {
|
||||
return internal::IndexedViewHelperIndicesWrapper<Indices, ColsAtCompileTime>::CreateIndexSequence(indices,
|
||||
derived().cols());
|
||||
}
|
||||
|
||||
template <typename Indices>
|
||||
inline IvcSizeType<Indices> ivcSize(const Indices& indices) const {
|
||||
return internal::IndexedViewHelperIndicesWrapper<Indices, SizeAtCompileTime>::CreateIndexSequence(indices,
|
||||
derived().size());
|
||||
;
|
||||
}
|
||||
|
||||
// this helper class assumes internal::valid_indexed_view_overload<RowIndices, ColIndices>::value == true
|
||||
template <typename RowIndices, typename ColIndices, typename EnableIf = void>
|
||||
struct IndexedViewSelector;
|
||||
|
||||
// Generic
|
||||
template <typename RowIndices, typename ColIndices>
|
||||
struct IndexedViewSelector<
|
||||
RowIndices, ColIndices,
|
||||
std::enable_if_t<
|
||||
internal::traits<IndexedView<Derived, IvcRowType<RowIndices>, IvcColType<ColIndices>>>::ReturnAsIndexedView>> {
|
||||
using ReturnType = IndexedView<Derived, IvcRowType<RowIndices>, IvcColType<ColIndices>>;
|
||||
using ConstReturnType = IndexedView<const Derived, IvcRowType<RowIndices>, IvcColType<ColIndices>>;
|
||||
|
||||
static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
return ReturnType(derived, derived.ivcRow(rowIndices), derived.ivcCol(colIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) {
|
||||
return ConstReturnType(derived, derived.ivcRow(rowIndices), derived.ivcCol(colIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// Block
|
||||
template <typename RowIndices, typename ColIndices>
|
||||
struct IndexedViewSelector<RowIndices, ColIndices,
|
||||
std::enable_if_t<internal::traits<
|
||||
IndexedView<Derived, IvcRowType<RowIndices>, IvcColType<ColIndices>>>::ReturnAsBlock>> {
|
||||
using ActualRowIndices = IvcRowType<RowIndices>;
|
||||
using ActualColIndices = IvcColType<ColIndices>;
|
||||
using IndexedViewType = IndexedView<Derived, ActualRowIndices, ActualColIndices>;
|
||||
using ConstIndexedViewType = IndexedView<const Derived, ActualRowIndices, ActualColIndices>;
|
||||
using ReturnType = typename internal::traits<IndexedViewType>::BlockType;
|
||||
using ConstReturnType = typename internal::traits<ConstIndexedViewType>::BlockType;
|
||||
using RowHelper = internal::IndexedViewHelper<ActualRowIndices>;
|
||||
using ColHelper = internal::IndexedViewHelper<ActualColIndices>;
|
||||
|
||||
static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
auto actualRowIndices = derived.ivcRow(rowIndices);
|
||||
auto actualColIndices = derived.ivcCol(colIndices);
|
||||
return ReturnType(derived, RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices),
|
||||
RowHelper::size(actualRowIndices), ColHelper::size(actualColIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) {
|
||||
auto actualRowIndices = derived.ivcRow(rowIndices);
|
||||
auto actualColIndices = derived.ivcCol(colIndices);
|
||||
return ConstReturnType(derived, RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices),
|
||||
RowHelper::size(actualRowIndices), ColHelper::size(actualColIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// Scalar
|
||||
template <typename RowIndices, typename ColIndices>
|
||||
struct IndexedViewSelector<RowIndices, ColIndices,
|
||||
std::enable_if_t<internal::traits<
|
||||
IndexedView<Derived, IvcRowType<RowIndices>, IvcColType<ColIndices>>>::ReturnAsScalar>> {
|
||||
using ReturnType = typename DenseBase<Derived>::Scalar&;
|
||||
using ConstReturnType = typename DenseBase<Derived>::CoeffReturnType;
|
||||
using ActualRowIndices = IvcRowType<RowIndices>;
|
||||
using ActualColIndices = IvcColType<ColIndices>;
|
||||
using RowHelper = internal::IndexedViewHelper<ActualRowIndices>;
|
||||
using ColHelper = internal::IndexedViewHelper<ActualColIndices>;
|
||||
static inline ReturnType run(Derived& derived, const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
auto actualRowIndices = derived.ivcRow(rowIndices);
|
||||
auto actualColIndices = derived.ivcCol(colIndices);
|
||||
return derived(RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) {
|
||||
auto actualRowIndices = derived.ivcRow(rowIndices);
|
||||
auto actualColIndices = derived.ivcCol(colIndices);
|
||||
return derived(RowHelper::first(actualRowIndices), ColHelper::first(actualColIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// this helper class assumes internal::is_valid_index_type<Indices>::value == false
|
||||
template <typename Indices, typename EnableIf = void>
|
||||
struct VectorIndexedViewSelector;
|
||||
|
||||
// Generic
|
||||
template <typename Indices>
|
||||
struct VectorIndexedViewSelector<
|
||||
Indices, std::enable_if_t<!internal::is_single_range<IvcSizeType<Indices>>::value &&
|
||||
internal::IndexedViewHelper<IvcSizeType<Indices>>::IncrAtCompileTime != 1>> {
|
||||
static constexpr bool IsRowMajor = DenseBase<Derived>::IsRowMajor;
|
||||
using ZeroIndex = internal::SingleRange<Index(0)>;
|
||||
using RowMajorReturnType = IndexedView<Derived, ZeroIndex, IvcSizeType<Indices>>;
|
||||
using ConstRowMajorReturnType = IndexedView<const Derived, ZeroIndex, IvcSizeType<Indices>>;
|
||||
|
||||
using ColMajorReturnType = IndexedView<Derived, IvcSizeType<Indices>, ZeroIndex>;
|
||||
using ConstColMajorReturnType = IndexedView<const Derived, IvcSizeType<Indices>, ZeroIndex>;
|
||||
|
||||
using ReturnType = typename internal::conditional<IsRowMajor, RowMajorReturnType, ColMajorReturnType>::type;
|
||||
using ConstReturnType =
|
||||
typename internal::conditional<IsRowMajor, ConstRowMajorReturnType, ConstColMajorReturnType>::type;
|
||||
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor, bool> = true>
|
||||
static inline RowMajorReturnType run(Derived& derived, const Indices& indices) {
|
||||
return RowMajorReturnType(derived, ZeroIndex(0), derived.ivcCol(indices));
|
||||
}
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<UseRowMajor, bool> = true>
|
||||
static inline ConstRowMajorReturnType run(const Derived& derived, const Indices& indices) {
|
||||
return ConstRowMajorReturnType(derived, ZeroIndex(0), derived.ivcCol(indices));
|
||||
}
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor, bool> = true>
|
||||
static inline ColMajorReturnType run(Derived& derived, const Indices& indices) {
|
||||
return ColMajorReturnType(derived, derived.ivcRow(indices), ZeroIndex(0));
|
||||
}
|
||||
template <bool UseRowMajor = IsRowMajor, std::enable_if_t<!UseRowMajor, bool> = true>
|
||||
static inline ConstColMajorReturnType run(const Derived& derived, const Indices& indices) {
|
||||
return ConstColMajorReturnType(derived, derived.ivcRow(indices), ZeroIndex(0));
|
||||
}
|
||||
};
|
||||
|
||||
// Block
|
||||
template <typename Indices>
|
||||
struct VectorIndexedViewSelector<
|
||||
Indices, std::enable_if_t<!internal::is_single_range<IvcSizeType<Indices>>::value &&
|
||||
internal::IndexedViewHelper<IvcSizeType<Indices>>::IncrAtCompileTime == 1>> {
|
||||
using Helper = internal::IndexedViewHelper<IvcSizeType<Indices>>;
|
||||
using ReturnType = VectorBlock<Derived, Helper::SizeAtCompileTime>;
|
||||
using ConstReturnType = VectorBlock<const Derived, Helper::SizeAtCompileTime>;
|
||||
static inline ReturnType run(Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = derived.ivcSize(indices);
|
||||
return ReturnType(derived, Helper::first(actualIndices), Helper::size(actualIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = derived.ivcSize(indices);
|
||||
return ConstReturnType(derived, Helper::first(actualIndices), Helper::size(actualIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// Symbolic
|
||||
template <typename Indices>
|
||||
struct VectorIndexedViewSelector<Indices, std::enable_if_t<internal::is_single_range<IvcSizeType<Indices>>::value>> {
|
||||
using ReturnType = typename DenseBase<Derived>::Scalar&;
|
||||
using ConstReturnType = typename DenseBase<Derived>::CoeffReturnType;
|
||||
using Helper = internal::IndexedViewHelper<IvcSizeType<Indices>>;
|
||||
static inline ReturnType run(Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = derived.ivcSize(indices);
|
||||
return derived(Helper::first(actualIndices));
|
||||
}
|
||||
static inline ConstReturnType run(const Derived& derived, const Indices& indices) {
|
||||
auto actualIndices = derived.ivcSize(indices);
|
||||
return derived(Helper::first(actualIndices));
|
||||
}
|
||||
};
|
||||
|
||||
// SFINAE dummy types
|
||||
|
||||
template <typename RowIndices, typename ColIndices>
|
||||
@ -211,23 +33,25 @@ public:
|
||||
// non-const versions
|
||||
|
||||
template <typename RowIndices, typename ColIndices>
|
||||
using IndexedViewType = typename IndexedViewSelector<RowIndices, ColIndices>::ReturnType;
|
||||
using IndexedViewType = typename internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::ReturnType;
|
||||
|
||||
template <typename RowIndices, typename ColIndices, EnableOverload<RowIndices, ColIndices> = true>
|
||||
IndexedViewType<RowIndices, ColIndices> operator()(const RowIndices& rowIndices, const ColIndices& colIndices) {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), rowIndices, colIndices);
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), rowIndices, colIndices);
|
||||
}
|
||||
|
||||
template <typename RowType, size_t RowSize, typename ColIndices, typename RowIndices = Array<RowType, RowSize, 1>,
|
||||
EnableOverload<RowIndices, ColIndices> = true>
|
||||
IndexedViewType<RowIndices, ColIndices> operator()(const RowType (&rowIndices)[RowSize], const ColIndices& colIndices) {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices}, colIndices);
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices},
|
||||
colIndices);
|
||||
}
|
||||
|
||||
template <typename RowIndices, typename ColType, size_t ColSize, typename ColIndices = Array<ColType, ColSize, 1>,
|
||||
EnableOverload<RowIndices, ColIndices> = true>
|
||||
IndexedViewType<RowIndices, ColIndices> operator()(const RowIndices& rowIndices, const ColType (&colIndices)[ColSize]) {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), rowIndices, ColIndices{colIndices});
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), rowIndices,
|
||||
ColIndices{colIndices});
|
||||
}
|
||||
|
||||
template <typename RowType, size_t RowSize, typename ColType, size_t ColSize,
|
||||
@ -235,32 +59,35 @@ template <typename RowType, size_t RowSize, typename ColType, size_t ColSize,
|
||||
EnableOverload<RowIndices, ColIndices> = true>
|
||||
IndexedViewType<RowIndices, ColIndices> operator()(const RowType (&rowIndices)[RowSize],
|
||||
const ColType (&colIndices)[ColSize]) {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices}, ColIndices{colIndices});
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices},
|
||||
ColIndices{colIndices});
|
||||
}
|
||||
|
||||
// const versions
|
||||
|
||||
template <typename RowIndices, typename ColIndices>
|
||||
using ConstIndexedViewType = typename IndexedViewSelector<RowIndices, ColIndices>::ConstReturnType;
|
||||
using ConstIndexedViewType = typename internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::ConstReturnType;
|
||||
|
||||
template <typename RowIndices, typename ColIndices, EnableConstOverload<RowIndices, ColIndices> = true>
|
||||
ConstIndexedViewType<RowIndices, ColIndices> operator()(const RowIndices& rowIndices,
|
||||
const ColIndices& colIndices) const {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), rowIndices, colIndices);
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), rowIndices, colIndices);
|
||||
}
|
||||
|
||||
template <typename RowType, size_t RowSize, typename ColIndices, typename RowIndices = Array<RowType, RowSize, 1>,
|
||||
EnableConstOverload<RowIndices, ColIndices> = true>
|
||||
ConstIndexedViewType<RowIndices, ColIndices> operator()(const RowType (&rowIndices)[RowSize],
|
||||
const ColIndices& colIndices) const {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices}, colIndices);
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices},
|
||||
colIndices);
|
||||
}
|
||||
|
||||
template <typename RowIndices, typename ColType, size_t ColSize, typename ColIndices = Array<ColType, ColSize, 1>,
|
||||
EnableConstOverload<RowIndices, ColIndices> = true>
|
||||
ConstIndexedViewType<RowIndices, ColIndices> operator()(const RowIndices& rowIndices,
|
||||
const ColType (&colIndices)[ColSize]) const {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), rowIndices, ColIndices{colIndices});
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), rowIndices,
|
||||
ColIndices{colIndices});
|
||||
}
|
||||
|
||||
template <typename RowType, size_t RowSize, typename ColType, size_t ColSize,
|
||||
@ -268,7 +95,8 @@ template <typename RowType, size_t RowSize, typename ColType, size_t ColSize,
|
||||
EnableConstOverload<RowIndices, ColIndices> = true>
|
||||
ConstIndexedViewType<RowIndices, ColIndices> operator()(const RowType (&rowIndices)[RowSize],
|
||||
const ColType (&colIndices)[ColSize]) const {
|
||||
return IndexedViewSelector<RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices}, ColIndices{colIndices});
|
||||
return internal::IndexedViewSelector<Derived, RowIndices, ColIndices>::run(derived(), RowIndices{rowIndices},
|
||||
ColIndices{colIndices});
|
||||
}
|
||||
|
||||
// Public API for 1D vectors/arrays
|
||||
@ -276,37 +104,37 @@ ConstIndexedViewType<RowIndices, ColIndices> operator()(const RowType (&rowIndic
|
||||
// non-const versions
|
||||
|
||||
template <typename Indices>
|
||||
using VectorIndexedViewType = typename VectorIndexedViewSelector<Indices>::ReturnType;
|
||||
using VectorIndexedViewType = typename internal::VectorIndexedViewSelector<Derived, Indices>::ReturnType;
|
||||
|
||||
template <typename Indices, EnableVectorOverload<Indices> = true>
|
||||
VectorIndexedViewType<Indices> operator()(const Indices& indices) {
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorIndexedViewSelector<Indices>::run(derived(), indices);
|
||||
return internal::VectorIndexedViewSelector<Derived, Indices>::run(derived(), indices);
|
||||
}
|
||||
|
||||
template <typename IndexType, size_t Size, typename Indices = Array<IndexType, Size, 1>,
|
||||
EnableVectorOverload<Indices> = true>
|
||||
VectorIndexedViewType<Indices> operator()(const IndexType (&indices)[Size]) {
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorIndexedViewSelector<Indices>::run(derived(), Indices{indices});
|
||||
return internal::VectorIndexedViewSelector<Derived, Indices>::run(derived(), Indices{indices});
|
||||
}
|
||||
|
||||
// const versions
|
||||
|
||||
template <typename Indices>
|
||||
using ConstVectorIndexedViewType = typename VectorIndexedViewSelector<Indices>::ConstReturnType;
|
||||
using ConstVectorIndexedViewType = typename internal::VectorIndexedViewSelector<Derived, Indices>::ConstReturnType;
|
||||
|
||||
template <typename Indices, EnableConstVectorOverload<Indices> = true>
|
||||
ConstVectorIndexedViewType<Indices> operator()(const Indices& indices) const {
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorIndexedViewSelector<Indices>::run(derived(), indices);
|
||||
return internal::VectorIndexedViewSelector<Derived, Indices>::run(derived(), indices);
|
||||
}
|
||||
|
||||
template <typename IndexType, size_t Size, typename Indices = Array<IndexType, Size, 1>,
|
||||
EnableConstVectorOverload<Indices> = true>
|
||||
ConstVectorIndexedViewType<Indices> operator()(const IndexType (&indices)[Size]) const {
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorIndexedViewSelector<Indices>::run(derived(), Indices{indices});
|
||||
return internal::VectorIndexedViewSelector<Derived, Indices>::run(derived(), Indices{indices});
|
||||
}
|
||||
|
||||
#else // EIGEN_PARSED_BY_DOXYGEN
|
||||
|
@ -447,7 +447,7 @@ void check_indexed_view() {
|
||||
|
||||
// Check compilation of varying integer types as index types:
|
||||
Index i = n / 2;
|
||||
short i_short(i);
|
||||
short i_short = static_cast<short>(i);
|
||||
std::size_t i_sizet(i);
|
||||
VERIFY_IS_EQUAL(a(i), a.coeff(i_short));
|
||||
VERIFY_IS_EQUAL(a(i), a.coeff(i_sizet));
|
||||
@ -812,7 +812,7 @@ void check_tutorial_examples() {
|
||||
{
|
||||
std::vector<int> ind{4, 2, 5, 5, 3};
|
||||
auto slice1 = A(all, ind);
|
||||
for (int i = 0; i < ind.size(); ++i) {
|
||||
for (size_t i = 0; i < ind.size(); ++i) {
|
||||
VERIFY_IS_EQUAL(slice1.col(i), A.col(ind[i]));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user