// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2017 Daniele Panozzo // // 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_CACHED_H #define IGL_SLICE_CACHED_H #include "igl_inline.h" #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #include #include namespace igl { // Act like the matlab X(row_indices,col_indices) operator, where row_indices, // col_indices are non-negative integer indices. This is a fast version of // igl::slice that can analyze and store the sparsity structure. It is slower // at the irst evaluation (slice_cached_precompute), but faster on the // subsequent ones. // // Inputs: // X m by n matrix // R list of row indices // C list of column indices // // Output: // Y #R by #C matrix // data Temporary data used by slice_cached to repeat this operation // // Usage: // // // Construct and slice up Laplacian // SparseMatrix L,L_sliced; // igl::cotmatrix(V,F,L); // // Normal igl::slice call // igl::slice(L,in,in,L_in_in); // // Fast version // static VectorXi data; // static or saved in a global state // if (data.size() == 0) // igl::slice_cached_precompute(L,in,in,data,L_sliced); // else // igl::slice_cached(L,data,L_sliced); template IGL_INLINE void slice_cached_precompute( const Eigen::SparseMatrix& X, const Eigen::Matrix & R, const Eigen::Matrix & C, Eigen::MatrixBase& data, Eigen::SparseMatrix& Y ); template IGL_INLINE void slice_cached( const Eigen::SparseMatrix& X, const Eigen::MatrixBase& data, Eigen::SparseMatrix& Y ); } #ifndef IGL_STATIC_LIBRARY # include "slice_cached.cpp" #endif #endif