// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2015 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #ifndef IGL_SLICE_MASK_H #define IGL_SLICE_MASK_H #include "igl_inline.h" #include #include namespace igl { /// Act like the matlab X(row_mask,col_mask) operator, where /// row_mask, col_mask are non-negative integer indices. /// /// @param[in] X m by n matrix /// @param[in] R m list of row bools /// @param[in] C n list of column bools /// @param[out] Y #trues-in-R by #trues-in-C matrix /// /// \see slice template IGL_INLINE void slice_mask( const Eigen::SparseMatrix & X, const Eigen::Array & R, const Eigen::Array & C, Eigen::SparseMatrix & Y); /// \overload /// /// \brief Wrapper to only slice in one direction /// /// @param[int] dim dimension to slice in 1 or 2, dim=1 --> X(R,:), dim=2 --> X(:,R) template IGL_INLINE void slice_mask( const Eigen::SparseMatrix & X, const Eigen::Array & R, const int dim, Eigen::SparseMatrix & Y); /// \overload /// /// \deprecated /// /// See slice.h for more details template IGL_INLINE void slice_mask( const Eigen::DenseBase & X, const Eigen::Array & R, const Eigen::Array & C, Eigen::PlainObjectBase & Y); template IGL_INLINE void slice_mask( const Eigen::DenseBase & X, const Eigen::Array & R, const int dim, Eigen::PlainObjectBase & Y); /// \overload /// \note This templating is bad because the return type might not have the same /// size as `DerivedX`. This will probably only work if DerivedX has Dynamic /// as it's non-trivial sizes or if the number of rows in R happens to equal /// the number of rows in `DerivedX`. template IGL_INLINE DerivedX slice_mask( const Eigen::DenseBase & X, const Eigen::Array & R, const Eigen::Array & C); /// \overload template IGL_INLINE DerivedX slice_mask( const Eigen::DenseBase & X, const Eigen::Array & R, const int dim); } #ifndef IGL_STATIC_LIBRARY # include "slice_mask.cpp" #endif #endif