mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Add support for plain-array as indices, e.g., mat({1,2,3,4})
This commit is contained in:
@@ -159,6 +159,12 @@ span(FirstType first, SizeType size) {
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename T>
|
||||
Index size(const T& x) { return x.size(); }
|
||||
|
||||
template<typename T,std::size_t N>
|
||||
Index size(const T (&x) [N]) { return N; }
|
||||
|
||||
template<typename T, int XprSize, typename EnableIf = void> struct get_compile_time_size {
|
||||
enum { value = Dynamic };
|
||||
};
|
||||
|
||||
@@ -566,6 +566,13 @@ template<typename Derived> class DenseBase
|
||||
derived(), internal::make_indexing(rowIndices,derived().rows()), internal::make_indexing(colIndices,derived().cols()));
|
||||
}
|
||||
|
||||
template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndices>
|
||||
IndexedView<const Derived,const RowIndicesT (&)[RowIndicesN],typename internal::MakeIndexing<ColIndices>::type>
|
||||
operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndices& colIndices) const {
|
||||
return IndexedView<const Derived,const RowIndicesT (&) [RowIndicesN],typename internal::MakeIndexing<ColIndices>::type>(
|
||||
derived(), rowIndices, internal::make_indexing(colIndices,derived().cols()));
|
||||
}
|
||||
|
||||
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
|
||||
#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
|
||||
#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
|
||||
|
||||
@@ -70,8 +70,8 @@ public:
|
||||
IndexedView(XprType& xpr, const T0& rowIndices, const T1& colIndices)
|
||||
: m_xpr(xpr), m_rowIndices(rowIndices), m_colIndices(colIndices)
|
||||
{}
|
||||
Index rows() const { return m_rowIndices.size(); }
|
||||
Index cols() const { return m_colIndices.size(); }
|
||||
Index rows() const { return internal::size(m_rowIndices); }
|
||||
Index cols() const { return internal::size(m_colIndices); }
|
||||
|
||||
/** \returns the nested expression */
|
||||
const typename internal::remove_all<XprType>::type&
|
||||
|
||||
Reference in New Issue
Block a user