Browse Source

better templates

Former-commit-id: d390da6dbe290652a8f444e7bae7e5592785dcf6
Alec Jacobson 8 years ago
parent
commit
2ecd74c82a
2 changed files with 19 additions and 21 deletions
  1. 12 18
      include/igl/sparse.cpp
  2. 7 3
      include/igl/sparse.h

+ 12 - 18
include/igl/sparse.cpp

@@ -23,10 +23,14 @@ IGL_INLINE void igl::sparse(
 }
 
 #include "verbose.h"
-template <class IndexVector, class ValueVector, typename T>
+template <
+  class IndexVectorI, 
+  class IndexVectorJ, 
+  class ValueVector, 
+  typename T>
 IGL_INLINE void igl::sparse(
-  const IndexVector & I,
-  const IndexVector & J,
+  const IndexVectorI & I,
+  const IndexVectorJ & J,
   const ValueVector & V,
   const size_t m,
   const size_t n,
@@ -103,20 +107,10 @@ IGL_INLINE Eigen::SparseMatrix<typename DerivedD::Scalar > igl::sparse(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, size_t, size_t, Eigen::SparseMatrix<double, 0, int>&);
-template void igl::sparse<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
-template Eigen::SparseMatrix<Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar, 0, int> igl::sparse<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&);
-template Eigen::SparseMatrix<Eigen::Matrix<double, -1, 1, 0, -1, 1>::Scalar, 0, int> igl::sparse<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&);
-template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int>&);
+// generated by autoexplicit.sh
+template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, std::complex<double> >(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, unsigned long, unsigned long, Eigen::SparseMatrix<std::complex<double>, 0, int>&);
+// generated by autoexplicit.sh
 template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int>&);
-
-#ifdef _WIN32
-template void igl::sparse<Eigen::Matrix<int,-1,1,0,-1,1>,Eigen::Matrix<double,-1,1,0,-1,1>,std::complex<double> >(Eigen::Matrix<int,-1,1,0,-1,1> const &,Eigen::Matrix<int,-1,1,0,-1,1> const &,Eigen::Matrix<double,-1,1,0,-1,1> const &,unsigned long long int,unsigned long long int,Eigen::SparseMatrix<std::complex<double>,0,int> &);
-#endif
-
-#ifndef _WIN32
-template void igl::sparse<Eigen::Matrix<int,-1,1,0,-1,1>,Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>,Eigen::Matrix<double,-1,1,0,-1,1> >,double>(Eigen::Matrix<int,-1,1,0,-1,1> const&,Eigen::Matrix<int,-1,1,0,-1,1> const&,Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>,Eigen::Matrix<double,-1,1,0,-1,1> > const&,unsigned long,unsigned long,Eigen::SparseMatrix<double,0,int>&);
-template void igl::sparse<Eigen::Matrix<int,-1,1,0,-1,1>,Eigen::Matrix<double,-1,1,0,-1,1>,std::complex<double> >(Eigen::Matrix<int,-1,1,0,-1,1> const&,Eigen::Matrix<int,-1,1,0,-1,1> const&,Eigen::Matrix<double,-1,1,0,-1,1> const&,unsigned long,unsigned long,Eigen::SparseMatrix<std::complex<double>,0,int>&);
-#endif
-
+// generated by autoexplicit.sh
+template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, unsigned long, unsigned long, Eigen::SparseMatrix<double, 0, int>&);
 #endif

+ 7 - 3
include/igl/sparse.h

@@ -39,10 +39,14 @@ namespace igl
     const IndexVector & J,
     const ValueVector & V,
     Eigen::SparseMatrix<T>& X);
-  template <class IndexVector, class ValueVector, typename T>
+  template <
+    class IndexVectorI, 
+    class IndexVectorJ, 
+    class ValueVector, 
+    typename T>
   IGL_INLINE void sparse(
-    const IndexVector & I,
-    const IndexVector & J,
+    const IndexVectorI & I,
+    const IndexVectorJ & J,
     const ValueVector & V,
     const size_t m,
     const size_t n,