浏览代码

Merge pull request #682 from danielepanozzo/master

Style fixes

Former-commit-id: e741a7a698b0c6b8917108c69089e1a4abace141
Daniele Panozzo 7 年之前
父节点
当前提交
5fc99b6f1d

+ 7 - 7
include/igl/AtA_cached.cpp

@@ -14,8 +14,8 @@
 template <typename Scalar>
 IGL_INLINE void igl::AtA_cached_precompute(
     const Eigen::SparseMatrix<Scalar>& A,
-    Eigen::SparseMatrix<Scalar>& AtA,
-    igl::AtA_cached_data& data)
+    igl::AtA_cached_data& data,
+    Eigen::SparseMatrix<Scalar>& AtA)
 {
   // 1 Compute At (this could be avoided, but performance-wise it will not make a difference)
   std::vector<std::vector<int> > Col_RowPtr;
@@ -106,14 +106,14 @@ IGL_INLINE void igl::AtA_cached_precompute(
   }
   data.I_outer.push_back(data.I_row.size()); // makes it more efficient to iterate later on
 
-  igl::AtA_cached(A,AtA,data);
+  igl::AtA_cached(A,data,AtA);
 }
 
 template <typename Scalar>
 IGL_INLINE void igl::AtA_cached(
     const Eigen::SparseMatrix<Scalar>& A,
-    Eigen::SparseMatrix<Scalar>& AtA,
-    const igl::AtA_cached_data& data)
+    const igl::AtA_cached_data& data,
+    Eigen::SparseMatrix<Scalar>& AtA)
 {
   for (unsigned i=0; i<data.I_outer.size()-1; ++i)
   {
@@ -125,6 +125,6 @@ IGL_INLINE void igl::AtA_cached(
 
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::AtA_cached<double>(Eigen::SparseMatrix<double, 0, int> const&, Eigen::SparseMatrix<double, 0, int>&, igl::AtA_cached_data const&);
-template void igl::AtA_cached_precompute<double>(Eigen::SparseMatrix<double, 0, int> const&, Eigen::SparseMatrix<double, 0, int>&, igl::AtA_cached_data&);
+template void igl::AtA_cached<double>(Eigen::SparseMatrix<double, 0, int> const&, igl::AtA_cached_data const&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::AtA_cached_precompute<double>(Eigen::SparseMatrix<double, 0, int> const&, igl::AtA_cached_data&, Eigen::SparseMatrix<double, 0, int>&);
 #endif

+ 8 - 6
include/igl/AtA_cached.h

@@ -44,20 +44,22 @@ namespace igl
   // AtA_data = igl::AtA_cached_data();
   // AtA_data.W = W;
   // if (s.AtA.rows() == 0)
-  //   igl::AtA_cached_precompute(s.A,s.AtA,s.AtA_data);
+  //   igl::AtA_cached_precompute(s.A,s.AtA_data,s.AtA);
   // else
-  //   igl::AtA_cached(s.A,s.AtA,s.AtA_data);
+  //   igl::AtA_cached(s.A,s.AtA_data,s.AtA);
   template <typename Scalar>
   IGL_INLINE void AtA_cached_precompute(
     const Eigen::SparseMatrix<Scalar>& A,
-    Eigen::SparseMatrix<Scalar>& AtA,
-    AtA_cached_data& data);
+    AtA_cached_data& data,
+    Eigen::SparseMatrix<Scalar>& AtA
+    );
 
   template <typename Scalar>
   IGL_INLINE void AtA_cached(
     const Eigen::SparseMatrix<Scalar>& A,
-    Eigen::SparseMatrix<Scalar>& AtA,
-    const AtA_cached_data& data);
+    const AtA_cached_data& data,
+    Eigen::SparseMatrix<Scalar>& AtA
+    );
   
 }
 

+ 11 - 9
include/igl/slice_cached.cpp

@@ -10,15 +10,16 @@
 #include <iostream>
 #include <vector>
 #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(
   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)
+  Eigen::MatrixBase<DerivedI>& data,
+  Eigen::SparseMatrix<TY>& Y
+  )
 {
   // Create a sparse matrix whose entries are the ids
   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(
   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)
     *(Y.valuePtr() + i) = *(X.valuePtr() + data[i]);
 }
 
 #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

+ 16 - 15
include/igl/slice_cached.h

@@ -39,24 +39,25 @@ namespace igl
   // // Fast version
   // static VectorXi data; // static or saved in a global state
   // 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
-  //   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

+ 7 - 7
include/igl/slim.cpp

@@ -34,9 +34,9 @@
 #include <Eigen/SparseCholesky>
 #include <Eigen/IterativeLinearSolvers>
 
-#include <igl/Timer.h>
-#include <igl/sparse_cached.h>
-#include <igl/AtA_cached.h>
+#include "Timer.h"
+#include "sparse_cached.h"
+#include "AtA_cached.h"
 
 #ifdef CHOLMOD
 #include <Eigen/CholmodSupport>
@@ -505,10 +505,10 @@ namespace igl
       if (s.A.rows() == 0)
       {
         s.A = Eigen::SparseMatrix<double>(s.dim * s.dim * s.f_n, s.dim * s.v_n);
-        igl::sparse_cached_precompute(IJV,s.A,s.A_data);
+        igl::sparse_cached_precompute(IJV,s.A_data,s.A);
       }
       else
-        igl::sparse_cached(IJV,s.A,s.A_data);
+        igl::sparse_cached(IJV,s.A_data,s.A);
       #else
       Eigen::SparseMatrix<double> A(s.dim * s.dim * s.f_n, s.dim * s.v_n);
       buildA(s,IJV);
@@ -534,9 +534,9 @@ namespace igl
       #ifdef SLIM_CACHED
       s.AtA_data.W = s.WGL_M;
       if (s.AtA.rows() == 0)
-        igl::AtA_cached_precompute(s.A,s.AtA,s.AtA_data);
+        igl::AtA_cached_precompute(s.A,s.AtA_data,s.AtA);
       else
-        igl::AtA_cached(s.A,s.AtA,s.AtA_data);
+        igl::AtA_cached(s.A,s.AtA_data,s.AtA);
 
       L = s.AtA + s.proximal_p * id_m; //add also a proximal 
       L.makeCompressed();

+ 10 - 10
include/igl/sparse_cached.cpp

@@ -18,8 +18,8 @@ template <typename DerivedI, typename Scalar>
 IGL_INLINE void igl::sparse_cached_precompute(
   const Eigen::MatrixBase<DerivedI> & I,
   const Eigen::MatrixBase<DerivedI> & J,
-  Eigen::SparseMatrix<Scalar>& X,
-  Eigen::VectorXi& data)
+  Eigen::VectorXi& data,
+  Eigen::SparseMatrix<Scalar>& X)
 {
   // Generates the triplets
   std::vector<Eigen::Triplet<double> > t(I.size());
@@ -33,8 +33,8 @@ IGL_INLINE void igl::sparse_cached_precompute(
 template <typename Scalar>
 IGL_INLINE void igl::sparse_cached_precompute(
   const std::vector<Eigen::Triplet<Scalar> >& triplets,
-  Eigen::SparseMatrix<Scalar>& X,
-  Eigen::VectorXi& data)
+  Eigen::VectorXi& data,
+  Eigen::SparseMatrix<Scalar>& X)
 {
     // Construct an empty sparse matrix
     X.setFromTriplets(triplets.begin(),triplets.end());
@@ -84,8 +84,8 @@ IGL_INLINE void igl::sparse_cached_precompute(
 template <typename Scalar>
 IGL_INLINE void igl::sparse_cached(
   const std::vector<Eigen::Triplet<Scalar> >& triplets,
-  Eigen::SparseMatrix<Scalar>& X,
-  const Eigen::VectorXi& data)
+  const Eigen::VectorXi& data,
+  Eigen::SparseMatrix<Scalar>& X)
 {
   assert(triplets.size() == data.size());
 
@@ -101,8 +101,8 @@ IGL_INLINE void igl::sparse_cached(
 template <typename DerivedV, typename Scalar>
 IGL_INLINE void igl::sparse_cached(
   const Eigen::MatrixBase<DerivedV>& V,
-  Eigen::SparseMatrix<Scalar>& X,
-  const Eigen::VectorXi& data)
+  const Eigen::VectorXi& data,
+  Eigen::SparseMatrix<Scalar>& X)
 {
   assert(V.size() == data.size());
 
@@ -117,6 +117,6 @@ IGL_INLINE void igl::sparse_cached(
 
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::sparse_cached_precompute<double>(std::vector<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index>, std::allocator<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index> > > const&, Eigen::SparseMatrix<double, 0, int>&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
-template void igl::sparse_cached<double>(std::vector<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index>, std::allocator<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index> > > const&, Eigen::SparseMatrix<double, 0, int>&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&);
+template void igl::sparse_cached<double>(std::vector<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index>, std::allocator<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index> > > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::sparse_cached_precompute<double>(std::vector<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index>, std::allocator<Eigen::Triplet<double, Eigen::SparseMatrix<double, 0, int>::Index> > > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, Eigen::SparseMatrix<double, 0, int>&);
 #endif

+ 11 - 8
include/igl/sparse_cached.h

@@ -52,26 +52,29 @@ namespace igl
   IGL_INLINE void sparse_cached_precompute(
     const Eigen::MatrixBase<DerivedI> & I,
     const Eigen::MatrixBase<DerivedI> & J,
-    Eigen::SparseMatrix<Scalar>& X,
-    Eigen::VectorXi& data);
+    Eigen::VectorXi& data,
+    Eigen::SparseMatrix<Scalar>& X
+    );
   
   template <typename Scalar>
   IGL_INLINE void sparse_cached_precompute(
     const std::vector<Eigen::Triplet<Scalar> >& triplets,
-    Eigen::SparseMatrix<Scalar>& X,
-    Eigen::VectorXi& data);
+    Eigen::VectorXi& data,
+    Eigen::SparseMatrix<Scalar>& X
+    );
 
   template <typename Scalar>
   IGL_INLINE void sparse_cached(
     const std::vector<Eigen::Triplet<Scalar> >& triplets,
-    Eigen::SparseMatrix<Scalar>& X,
-    const Eigen::VectorXi& data);
+    const Eigen::VectorXi& data,
+    Eigen::SparseMatrix<Scalar>& X);
 
   template <typename DerivedV, typename Scalar>
   IGL_INLINE void sparse_cached(
     const Eigen::MatrixBase<DerivedV>& V,
-    Eigen::SparseMatrix<Scalar>& X,
-    const Eigen::VectorXi& data);
+    const Eigen::VectorXi& data,
+    Eigen::SparseMatrix<Scalar>& X
+    );
   
 }