8 #ifndef DEM_BONES_INDEXING
9 #define DEM_BONES_INDEXING
12 #pragma warning(disable:4172)
15 #include <Eigen/Dense>
23 template<
class ArgType,
class RowIndexType,
class ColIndexType>
26 const RowIndexType &m_rowIndices;
27 const ColIndexType &m_colIndices;
29 typedef Eigen::Matrix<
typename ArgType::Scalar,
30 RowIndexType::SizeAtCompileTime,
31 ColIndexType::SizeAtCompileTime,
32 ArgType::Flags& Eigen::RowMajorBit?Eigen::RowMajor:Eigen::ColMajor,
33 RowIndexType::MaxSizeAtCompileTime,
36 : m_arg(arg), m_rowIndices(row_indices), m_colIndices(col_indices) {}
37 const typename ArgType::Scalar&
operator() (Eigen::Index row, Eigen::Index col)
const {
38 return m_arg(m_rowIndices[row], m_colIndices[col]);
45 template <
class ArgType,
class RowIndexType,
class ColIndexType>
47 indexing_row_col(
const Eigen::MatrixBase<ArgType>& arg,
const RowIndexType& row_indices,
const ColIndexType& col_indices) {
49 typedef typename Func::MatrixType MatrixType;
50 return MatrixType::NullaryExpr(row_indices.size(), col_indices.size(), Func(arg.derived(), row_indices, col_indices));
58 template<
class ArgType,
class RowIndexType>
61 const RowIndexType &m_rowIndices;
63 typedef Eigen::Matrix<
typename ArgType::Scalar,
64 RowIndexType::SizeAtCompileTime,
65 ArgType::ColsAtCompileTime,
66 ArgType::Flags& Eigen::RowMajorBit?Eigen::RowMajor:Eigen::ColMajor,
67 RowIndexType::MaxSizeAtCompileTime,
70 : m_arg(arg), m_rowIndices(row_indices) {}
71 const typename ArgType::Scalar&
operator() (Eigen::Index row, Eigen::Index col)
const {
72 return m_arg(m_rowIndices[row], col);
79 template <
class ArgType,
class RowIndexType>
81 indexing_row(
const Eigen::MatrixBase<ArgType>& arg,
const RowIndexType& row_indices) {
83 typedef typename Func::MatrixType MatrixType;
84 return MatrixType::NullaryExpr(row_indices.size(), arg.cols(), Func(arg.derived(), row_indices));
92 template<
class ArgType,
class IndexType>
95 const IndexType &m_indices;
97 typedef Eigen::Matrix<
typename ArgType::Scalar,
98 IndexType::SizeAtCompileTime,
101 IndexType::MaxSizeAtCompileTime,
104 : m_arg(arg), m_indices(indices) {}
105 const typename ArgType::Scalar&
operator() (Eigen::Index idx)
const {
106 return m_arg(m_indices[idx]);
113 template <
class ArgType,
class IndexType>
117 typedef typename Func::VectorType VectorType;
118 return VectorType::NullaryExpr(indices.size(), Func(arg.derived(), indices));