Ver Fonte

style fixes in slice_cached

Former-commit-id: d9df7f04ab8cef9e7b27bba2334f72759af44a8a
Daniele Panozzo há 7 anos atrás
pai
commit
9e63059a33
2 ficheiros alterados com 27 adições e 24 exclusões
  1. 11 9
      include/igl/slice_cached.cpp
  2. 16 15
      include/igl/slice_cached.h

+ 11 - 9
include/igl/slice_cached.cpp

@@ -10,15 +10,16 @@
 #include <iostream>
 #include <iostream>
 #include <vector>
 #include <vector>
 #include <utility>
 #include <utility>
-#include <igl/slice.h>
+#include "slice.h"
 
 
-template <typename TX, typename TY>
+template <typename TX, typename TY, typename DerivedI>
 IGL_INLINE void igl::slice_cached_precompute(
 IGL_INLINE void igl::slice_cached_precompute(
   const Eigen::SparseMatrix<TX>& X,
   const Eigen::SparseMatrix<TX>& X,
   const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
   const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
   const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
   const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
-  Eigen::SparseMatrix<TY>& Y,
-  Eigen::VectorXi& data)
+  Eigen::MatrixBase<DerivedI>& data,
+  Eigen::SparseMatrix<TY>& Y
+  )
 {
 {
   // Create a sparse matrix whose entries are the ids
   // Create a sparse matrix whose entries are the ids
   Eigen::SparseMatrix<unsigned> TS = X.template cast<unsigned>();
   Eigen::SparseMatrix<unsigned> TS = X.template cast<unsigned>();
@@ -39,17 +40,18 @@ IGL_INLINE void igl::slice_cached_precompute(
   }
   }
 }
 }
 
 
-template <typename TX, typename TY>
+template <typename TX, typename TY, typename DerivedI>
 IGL_INLINE void igl::slice_cached(
 IGL_INLINE void igl::slice_cached(
   const Eigen::SparseMatrix<TX>& X,
   const Eigen::SparseMatrix<TX>& X,
-  Eigen::SparseMatrix<TY>& Y,
-  const Eigen::VectorXi& data)
+  const Eigen::MatrixBase<DerivedI>& data,
+  Eigen::SparseMatrix<TY>& Y
+  )
 {
 {
   for (unsigned i=0; i<data.size(); ++i)
   for (unsigned i=0; i<data.size(); ++i)
     *(Y.valuePtr() + i) = *(X.valuePtr() + data[i]);
     *(Y.valuePtr() + i) = *(X.valuePtr() + data[i]);
 }
 }
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
-template void igl::slice_cached_precompute<double, double>(Eigen::SparseMatrix<double, 0, int> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int>&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
-template void igl::slice_cached<double, double>(Eigen::SparseMatrix<double, 0, int> const&, Eigen::SparseMatrix<double, 0, int>&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&);
+template void igl::slice_cached<double, double, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::slice_cached_precompute<double, double, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::SparseMatrix<double, 0, int>&);
 #endif
 #endif

+ 16 - 15
include/igl/slice_cached.h

@@ -39,24 +39,25 @@ namespace igl
   // // Fast version
   // // Fast version
   // static VectorXi data; // static or saved in a global state
   // static VectorXi data; // static or saved in a global state
   // if (data.size() == 0)
   // if (data.size() == 0)
-  //   igl::slice_cached_precompute(L,in,in,L_sliced,data);
+  //   igl::slice_cached_precompute(L,in,in,data,L_sliced);
   // else
   // else
-  //   igl::slice_cached(L,L_sliced,temp);
+  //   igl::slice_cached(L,data,L_sliced);
 
 
-  template <typename TX, typename TY>
-  IGL_INLINE void slice_cached_precompute(
-    const Eigen::SparseMatrix<TX>& X,
-    const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
-    const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
-    Eigen::SparseMatrix<TY>& Y,
-    Eigen::VectorXi& data);
-
-  template <typename TX, typename TY>
-  IGL_INLINE void slice_cached(
-    const Eigen::SparseMatrix<TX>& X,
-    Eigen::SparseMatrix<TY>& Y,
-    const Eigen::VectorXi& data);
+template <typename TX, typename TY, typename DerivedI>
+IGL_INLINE void slice_cached_precompute(
+  const Eigen::SparseMatrix<TX>& X,
+  const Eigen::Matrix<int,Eigen::Dynamic,1> & R,
+  const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
+  Eigen::MatrixBase<DerivedI>& data,
+  Eigen::SparseMatrix<TY>& Y
+  );
 
 
+template <typename TX, typename TY, typename DerivedI>
+IGL_INLINE void slice_cached(
+  const Eigen::SparseMatrix<TX>& X,
+  const Eigen::MatrixBase<DerivedI>& data,
+  Eigen::SparseMatrix<TY>& Y
+  );
 }
 }
 
 
 #ifndef IGL_STATIC_LIBRARY
 #ifndef IGL_STATIC_LIBRARY