Browse Source

rm depr nchoosek

Former-commit-id: a49c23f0c823cd956a5a4598572f8e8724db6a3e
Alec Jacobson 10 years ago
parent
commit
471f0c9c37

+ 2 - 0
RELEASE_HISTORY.md

@@ -54,6 +54,8 @@ dependency extra was absorbed.
 Old                                     | New
 --------------------------------------- | -----------------------------------
 `igl::angles`                           | `igl::internal_angles`
+`igl::get_modifiers`                    | [deleted]
+`igl::nchoosek(offset,K,N,std::vector)` | `igl::nchoosek(Eigen,K,Eigen)`
 `#include <igl/boost/components.h>`     | `#include <igl/components.h>`
 `#include <igl/boost/bfs_orient.h>`     | `#include <igl/bfs_orient.h>`
 `#include <igl/boost/orientable_patches.h>` | `#include <igl/orientable_patches.h>`

+ 9 - 5
include/igl/n_polyvector.cpp

@@ -345,8 +345,12 @@ IGL_INLINE void igl::PolyVectorFieldFinder<DerivedV, DerivedF>::getGeneralCoeffC
   Ck.resize(numConstrained,1);
   int n = cfW.cols()/3;
 
-  std::vector<std::vector<int> > allCombs;
-  igl::nchoosek(0,k+1,n,allCombs);
+  Eigen::MatrixXi allCombs;
+  {
+    Eigen::VectorXi V = Eigen::VectorXi::LinSpaced(n,0,n-1);
+    igl::nchoosek(V,k+1,allCombs);
+  }
+
 
   int ind = 0;
   for (int fi = 0; fi <numF; ++fi)
@@ -357,13 +361,13 @@ IGL_INLINE void igl::PolyVectorFieldFinder<DerivedV, DerivedF>::getGeneralCoeffC
     {
       std::complex<typename DerivedV::Scalar> ck(0);
 
-      for (int j = 0; j < allCombs.size(); ++j)
+      for (int j = 0; j < allCombs.rows(); ++j)
       {
         std::complex<typename DerivedV::Scalar> tk(1.);
         //collect products
-        for (int i = 0; i < allCombs[j].size(); ++i)
+        for (int i = 0; i < allCombs.cols(); ++i)
         {
-          int index = allCombs[j][i];
+          int index = allCombs(j,i);
 
           const Eigen::Matrix<typename DerivedV::Scalar, 1, 3> &w = cfW.block(fi,3*index,1,3);
           typename DerivedV::Scalar w0 = w.dot(b1);

+ 8 - 5
include/igl/n_polyvector_general.cpp

@@ -326,8 +326,11 @@ IGL_INLINE void igl::GeneralPolyVectorFieldFinder<DerivedV, DerivedF>::getGenera
   Ck.resize(numConstrained,1);
   // int n = rootsIndex.cols();
 
-  std::vector<std::vector<int>> allCombs;
-  igl::nchoosek(0,k+1,n,allCombs);
+  Eigen::MatrixXi allCombs;
+  {
+    Eigen::VectorXi V = Eigen::VectorXi::LinSpaced(n,0,n-1);
+    igl::nchoosek(V,k+1,allCombs);
+  }
 
   int ind = 0;
   for (int fi = 0; fi <numF; ++fi)
@@ -338,13 +341,13 @@ IGL_INLINE void igl::GeneralPolyVectorFieldFinder<DerivedV, DerivedF>::getGenera
     {
       std::complex<typename DerivedV::Scalar> ck(0);
 
-      for (int j = 0; j < allCombs.size(); ++j)
+      for (int j = 0; j < allCombs.rows(); ++j)
       {
         std::complex<typename DerivedV::Scalar> tk(1.);
         //collect products
-        for (int i = 0; i < allCombs[j].size(); ++i)
+        for (int i = 0; i < allCombs.cols(); ++i)
         {
-          int index = allCombs[j][i];
+          int index = allCombs(j,i);
 
           int ri = rootsIndex[index];
           Eigen::Matrix<typename DerivedV::Scalar, 1, 3> w;

+ 0 - 29
include/igl/nchoosek.cpp

@@ -66,35 +66,6 @@ IGL_INLINE void igl::nchoosek(
   doCombs(0,k);
 }
 
-IGL_INLINE void igl::nchoosek(
-  int offset,
-  int k,
-  int N,
-  std::vector<std::vector<int> > &allCombs)
-{
-  allCombs.clear();
-  std::vector<int> running;
-  const std::function<void(int,int)> doCombs = 
-    [&allCombs,&running,&N,&doCombs](int offset, int k)
-  {
-    if(k==0)
-    {
-      allCombs.push_back(running);
-      return;
-    }
-    for (int i = offset; i <= N - k; ++i) 
-    {
-      running.push_back(i);
-      doCombs(i+1,k-1);
-      running.pop_back();
-    }
-  };
-  doCombs(offset,k);
-
-}
-
-
-
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 #endif

+ 0 - 16
include/igl/nchoosek.h

@@ -35,22 +35,6 @@ namespace igl
     const Eigen::PlainObjectBase<DerivedV> & V,
     const int k,
     Eigen::PlainObjectBase<DerivedU> & U);
-  // This version has a strange interface and confusing parameters. It seems to
-  // reproduce matlab's 
-  //
-  //     nchoosek(3:5,2) 
-  //
-  // Then one should use
-  //
-  //     igl::nchoosek(3,2,6,res);
-  //
-  IGL_INLINE 
-  IGL_DEPRECATED(
-  void nchoosek(
-    int offset,
-    int k,
-    int N,
-    std::vector<std::vector<int> > &allCombs));
 }
 
 

+ 3 - 0
include/igl/slice.cpp

@@ -8,7 +8,10 @@
 #include "slice.h"
 #include "colon.h"
 
+#include <unsupported/Eigen/SparseExtra>
+#include <Eigen/Sparse>
 #include <vector>
+#include <complex>
 
 template <typename T>
 IGL_INLINE void igl::slice(