فهرست منبع

wrapper for Eigen's buggy LinSpaced

Former-commit-id: 4b497698bdab7e1612fbb5e22074a0e3ad2c0e4e
Alec Jacobson 8 سال پیش
والد
کامیت
36e5b8c423

+ 57 - 0
include/igl/LinSpaced.h

@@ -0,0 +1,57 @@
+#ifndef IGL_LINSPACED_H
+#define IGL_LINSPACED_H
+#include <Eigen/Core>
+// This function is not intended to be a permanent function of libigl. Rather
+// it is a "drop-in" workaround for documented bug in Eigen:
+// http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1383
+//
+// Replace: 
+//
+//     Eigen::VectorXi::LinSpaced(size,low,high);
+//
+// With:
+//
+//     igl::LinSpaced<Eigen::VectorXi>(size,low,high);
+//
+// Specifcally, this version will _always_ return an empty vector if size==0,
+// regardless of the values for low and high. If size != 0, then this simply
+// returns the result of Eigen::Derived::LinSpaced.
+//
+// Until this bug is fixed, we should also avoid calls to the member function
+// `.setLinSpaced`. This means replacing:
+//
+//     a.setLinSpaced(size,low,high);
+//
+// with
+//
+//     a = igl::LinSpaced<decltype(a) >(size,low,high);
+//
+namespace igl
+{
+  template <typename Derived>
+  inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType LinSpaced(
+    typename Derived::Index size,
+    const typename Derived::Scalar & low,
+    const typename Derived::Scalar & high);
+}
+
+// Implementation
+
+template <typename Derived>
+inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType 
+igl::LinSpaced(
+  typename Derived::Index size,
+  const typename Derived::Scalar & low,
+  const typename Derived::Scalar & high)
+{
+  if(size == 0)
+  {
+    // Force empty vector with correct "RandomAccessLinSpacedReturnType" type.
+    return Derived::LinSpaced(0,0,1);
+  }else
+  {
+    return Derived::LinSpaced(size,low,high);
+  }
+}
+
+#endif

+ 2 - 1
include/igl/colon.cpp

@@ -6,6 +6,7 @@
 // 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/.
 #include "colon.h"
+#include "LinSpaced.h"
 
 #include <cstdio>
 
@@ -17,7 +18,7 @@ IGL_INLINE void igl::colon(
   Eigen::Matrix<T,Eigen::Dynamic,1> & I)
 {
   const int size = ((hi-low)/step)+1;
-  I = Eigen::Matrix<T,Eigen::Dynamic,1>::LinSpaced(size,low,low+step*(size-1));
+  I = igl::LinSpaced<Eigen::Matrix<T,Eigen::Dynamic,1> >(size,low,low+step*(size-1));
 }
 
 template <typename L,typename H,typename T>

+ 2 - 2
include/igl/copyleft/cgal/closest_facet.cpp

@@ -15,6 +15,7 @@
 #include "order_facets_around_edge.h"
 #include "submesh_aabb_tree.h"
 #include "../../vertex_triangle_adjacency.h"
+#include "../../LinSpaced.h"
 //#include "../../writePLY.h"
 
 template<
@@ -484,8 +485,7 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
     Eigen::PlainObjectBase<DerivedR>& R,
     Eigen::PlainObjectBase<DerivedS>& S) {
   const size_t num_faces = F.rows();
-  Eigen::VectorXi I(num_faces);
-  I.setLinSpaced(num_faces, 0, num_faces-1);
+  Eigen::VectorXi I = igl::LinSpaced<Eigen::VectorXi>(num_faces, 0, num_faces-1);
   igl::copyleft::cgal::closest_facet(V, F, I, P, uE2E, EMAP, R, S);
 }
 

+ 3 - 2
include/igl/copyleft/cgal/component_inside_component.cpp

@@ -8,6 +8,7 @@
 #include "component_inside_component.h"
 
 #include "order_facets_around_edge.h"
+#include "../../LinSpaced.h"
 #include "points_inside_component.h"
 
 #include <CGAL/AABB_tree.h>
@@ -53,8 +54,8 @@ IGL_INLINE bool igl::copyleft::cgal::component_inside_component(
         throw "Component inside test cannot be done on empty component!";
     }
     Eigen::VectorXi I1(F1.rows()), I2(F2.rows());
-    I1.setLinSpaced(F1.rows(), 0, F1.rows()-1);
-    I2.setLinSpaced(F2.rows(), 0, F2.rows()-1);
+    I1 = igl::LinSpaced<Eigen::VectorXi>(F1.rows(), 0, F1.rows()-1);
+    I2 = igl::LinSpaced<Eigen::VectorXi>(F2.rows(), 0, F2.rows()-1);
     return igl::copyleft::cgal::component_inside_component(V1, F1, I1, V2, F2, I2);
 }
 

+ 3 - 2
include/igl/copyleft/cgal/minkowski_sum.cpp

@@ -9,6 +9,7 @@
 #include "mesh_boolean.h"
 
 #include "../../slice_mask.h"
+#include "../../LinSpaced.h"
 #include "../../unique.h"
 #include "../../get_seconds.h"
 #include "../../edges.h"
@@ -228,7 +229,7 @@ IGL_INLINE void igl::copyleft::cgal::minkowski_sum(
   MatrixXI GT(mp+mn,3);
   GT<< slice_mask(FA,N,1), slice_mask((FA.array()+n).eval(),P,1);
   // J indexes FA for parts at s and m+FA for parts at d
-  J = DerivedJ::LinSpaced(m,0,m-1);
+  J = igl::LinSpaced<DerivedJ >(m,0,m-1);
   DerivedJ JT(mp+mn);
   JT << slice_mask(J,P,1), slice_mask(J,N,1);
   JT.block(mp,0,mn,1).array()+=m;
@@ -281,7 +282,7 @@ IGL_INLINE void igl::copyleft::cgal::minkowski_sum(
     }
     Matrix<bool,Dynamic,1> M = Matrix<bool,Dynamic,1>::Zero(m,1);
     {
-      VectorXI P = VectorXI::LinSpaced(d,0,d-1);
+      VectorXI P = igl::LinSpaced<VectorXI >(d,0,d-1);
       for(int p = 0;p<d;p++)
       {
         for(int f = 0;f<m;f++)

+ 2 - 1
include/igl/copyleft/cgal/peel_outer_hull_layers.cpp

@@ -7,6 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "peel_outer_hull_layers.h"
 #include "outer_hull.h"
+#include "../../LinSpaced.h"
 #include <vector>
 #include <iostream>
 //#define IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
@@ -50,7 +51,7 @@ IGL_INLINE size_t igl::copyleft::cgal::peel_outer_hull_layers(
   I.resize(m,1);
   flip.resize(m,1);
   // Keep track of index map
-  MatrixXI IM = MatrixXI::LinSpaced(m,0,m-1);
+  MatrixXI IM = igl::LinSpaced<MatrixXI >(m,0,m-1);
   // This is O(n * layers)
   MatrixXI P(m,1);
   Index iter = 0;

+ 9 - 9
include/igl/copyleft/cgal/points_inside_component.cpp

@@ -6,19 +6,20 @@
 // 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/.
 #include "points_inside_component.h"
-
-#include <cassert>
-#include <list>
-#include <limits>
-#include <vector>
+#include "../../LinSpaced.h"
+#include "order_facets_around_edge.h"
+#include "assign_scalar.h"
 
 #include <CGAL/AABB_tree.h>
 #include <CGAL/AABB_traits.h>
 #include <CGAL/AABB_triangle_primitive.h>
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 
-#include "order_facets_around_edge.h"
-#include "assign_scalar.h"
+#include <cassert>
+#include <list>
+#include <limits>
+#include <vector>
+
 
 namespace igl {
   namespace copyleft 
@@ -332,8 +333,7 @@ IGL_INLINE void igl::copyleft::cgal::points_inside_component(
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedP>& P,
         Eigen::PlainObjectBase<DerivedB>& inside) {
-    Eigen::VectorXi I(F.rows());
-    I.setLinSpaced(F.rows(), 0, F.rows()-1);
+    Eigen::VectorXi I = igl::LinSpaced<Eigen::VectorXi>(F.rows(), 0, F.rows()-1);
     igl::copyleft::cgal::points_inside_component(V, F, I, P, inside);
 }
 

+ 2 - 2
include/igl/copyleft/cgal/propagate_winding_numbers.cpp

@@ -15,6 +15,7 @@
 #include "../../writeOBJ.h"
 #include "../../writePLY.h"
 #include "../../get_seconds.h"
+#include "../../LinSpaced.h"
 #include "order_facets_around_edge.h"
 #include "outer_facet.h"
 #include "closest_facet.h"
@@ -220,8 +221,7 @@ IGL_INLINE bool igl::copyleft::cgal::propagate_winding_numbers(
 
   size_t outer_facet;
   bool flipped;
-  Eigen::VectorXi I;
-  I.setLinSpaced(num_faces, 0, num_faces-1);
+  Eigen::VectorXi I = igl::LinSpaced<Eigen::VectorXi>(num_faces, 0, num_faces-1);
   igl::copyleft::cgal::outer_facet(V, F, I, outer_facet, flipped);
 #ifdef PROPAGATE_WINDING_NUMBER_TIMING
   log_time("outer_facet");

+ 4 - 1
include/igl/copyleft/cgal/remesh_intersections.cpp

@@ -10,6 +10,7 @@
 #include "assign_scalar.h"
 #include "projected_cdt.h"
 #include "../../get_seconds.h"
+#include "../../LinSpaced.h"
 #include "../../unique.h"
 
 #include <vector>
@@ -447,7 +448,9 @@ IGL_INLINE void igl::copyleft::cgal::remesh_intersections(
       std::transform(FF.data(), FF.data() + FF.rows()*FF.cols(),
           FF.data(), [&vv_to_unique](const typename DerivedFF::Scalar& a)
           { return vv_to_unique[a]; });
-      IM.setLinSpaced(unique_vv.rows(), 0, unique_vv.rows()-1);
+      IM = igl::LinSpaced<
+        Eigen::Matrix<typename DerivedIM::Scalar, Eigen::Dynamic,1 >
+        >(unique_vv.rows(), 0, unique_vv.rows()-1);
     }else 
     {
       // Vertices with the same coordinates would be represented by one vertex.

+ 3 - 2
include/igl/copyleft/comiso/miq.cpp

@@ -10,6 +10,7 @@
 #include "../../local_basis.h"
 #include "../../triangle_triangle_adjacency.h"
 #include "../../cut_mesh.h"
+#include "../../LinSpaced.h"
 
 // includes for VertexIndexing
 #include "../../HalfEdgeIterator.h"
@@ -830,8 +831,8 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddToR
 template <typename DerivedV, typename DerivedF>
 IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildLaplacianMatrix(double vfscale)
 {
-  Eigen::VectorXi idx  = Eigen::VectorXi::LinSpaced(Vcut.rows(), 0, 2*Vcut.rows()-2);
-  Eigen::VectorXi idx2 = Eigen::VectorXi::LinSpaced(Vcut.rows(), 1, 2*Vcut.rows()-1);
+  Eigen::VectorXi idx  = igl::LinSpaced<Eigen::VectorXi >(Vcut.rows(), 0, 2*Vcut.rows()-2);
+  Eigen::VectorXi idx2 = igl::LinSpaced<Eigen::VectorXi >(Vcut.rows(), 1, 2*Vcut.rows()-1);
 
   // get gradient matrix
   Eigen::SparseMatrix<double> G(Fcut.rows() * 3, Vcut.rows());

+ 10 - 9
include/igl/n_polyvector.cpp

@@ -6,18 +6,19 @@
 // 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/.
 
-#include <complex>
-#include <igl/n_polyvector.h>
-#include <igl/edge_topology.h>
-#include <igl/local_basis.h>
-#include <igl/nchoosek.h>
-#include <igl/slice.h>
-#include <igl/polyroots.h>
-#include <igl/igl_inline.h>
+#include "LinSpaced.h"
+#include "n_polyvector.h"
+#include "edge_topology.h"
+#include "local_basis.h"
+#include "nchoosek.h"
+#include "slice.h"
+#include "polyroots.h"
+#include "igl_inline.h"
 #include <Eigen/Sparse>
 
 #include <Eigen/Geometry>
 #include <iostream>
+#include <complex>
 
 namespace igl {
   template <typename DerivedV, typename DerivedF>
@@ -348,7 +349,7 @@ IGL_INLINE void igl::PolyVectorFieldFinder<DerivedV, DerivedF>::getGeneralCoeffC
 
   Eigen::MatrixXi allCombs;
   {
-    Eigen::VectorXi V = Eigen::VectorXi::LinSpaced(n,0,n-1);
+    Eigen::VectorXi V = igl::LinSpaced<Eigen::VectorXi >(n,0,n-1);
     igl::nchoosek(V,k+1,allCombs);
   }
 

+ 8 - 7
include/igl/n_polyvector_general.cpp

@@ -6,12 +6,13 @@
 // 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/.
 
-#include <igl/n_polyvector_general.h>
-#include <igl/edge_topology.h>
-#include <igl/local_basis.h>
-#include <igl/nchoosek.h>
-#include <igl/slice.h>
-#include <igl/polyroots.h>
+#include "LinSpaced.h"
+#include "n_polyvector_general.h"
+#include "edge_topology.h"
+#include "local_basis.h"
+#include "nchoosek.h"
+#include "slice.h"
+#include "polyroots.h"
 #include <Eigen/Sparse>
 #include <Eigen/Geometry>
 #include <iostream>
@@ -323,7 +324,7 @@ IGL_INLINE void igl::GeneralPolyVectorFieldFinder<DerivedV, DerivedF>::getGenera
 
   Eigen::MatrixXi allCombs;
   {
-    Eigen::VectorXi V = Eigen::VectorXi::LinSpaced(n,0,n-1);
+    Eigen::VectorXi V = igl::LinSpaced<Eigen::VectorXi >(n,0,n-1);
     igl::nchoosek(V,k+1,allCombs);
   }
 

+ 3 - 2
include/igl/normal_derivative.cpp

@@ -5,6 +5,7 @@
 // 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/.
+#include "LinSpaced.h"
 #include "normal_derivative.h"
 #include "cotmatrix_entries.h"
 #include "slice.h"
@@ -48,7 +49,7 @@ IGL_INLINE void igl::normal_derivative(
       MatrixXi DDI(m,24);
       for(size_t f = 0;f<4;f++)
       {
-        const auto & I = (VectorXi::LinSpaced(m,0,m-1).array()+f*m).eval();
+        const auto & I = (igl::LinSpaced<VectorXi >(m,0,m-1).array()+f*m).eval();
         for(size_t r = 0;r<6;r++)
         {
           DDI.col(f*6+r) = I;
@@ -83,7 +84,7 @@ IGL_INLINE void igl::normal_derivative(
       MatrixXi DDI(m,12);
       for(size_t f = 0;f<3;f++)
       {
-        const auto & I = (VectorXi::LinSpaced(m,0,m-1).array()+f*m).eval();
+        const auto & I = (igl::LinSpaced<VectorXi >(m,0,m-1).array()+f*m).eval();
         for(size_t r = 0;r<4;r++)
         {
           DDI.col(f*4+r) = I;

+ 2 - 1
include/igl/ramer_douglas_peucker.cpp

@@ -1,5 +1,6 @@
 #include "ramer_douglas_peucker.h"
 
+#include "LinSpaced.h"
 #include "find.h"
 #include "cumsum.h"
 #include "histc.h"
@@ -100,7 +101,7 @@ IGL_INLINE void igl::ramer_douglas_peucker(
   Eigen::VectorXi B;
   {
     Eigen::VectorXi N;
-    histc(Eigen::VectorXi::LinSpaced(n,0,n-1),J,N,B);
+    histc(igl::LinSpaced<Eigen::VectorXi >(n,0,n-1),J,N,B);
   }
   // Add extra point at end
   J.conservativeResize(J.size()+1);

+ 2 - 2
include/igl/setdiff.cpp

@@ -6,7 +6,7 @@
 // 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/.
 #include "setdiff.h"
-#include "colon.h"
+#include "LinSpaced.h"
 #include "list_to_matrix.h"
 #include "sort.h"
 #include "unique.h"
@@ -42,7 +42,7 @@ IGL_INLINE void igl::setdiff(
       }
     }
     assert(k == C.size());
-    IA = Eigen::Matrix<typename DerivedIA::Scalar,Eigen::Dynamic,1>::LinSpaced(
+    IA = igl::LinSpaced<Eigen::Matrix<typename DerivedIA::Scalar,Eigen::Dynamic,1> >(
       C.size(),0,C.size()-1);
   }
 

+ 1 - 1
include/igl/signed_distance.cpp

@@ -217,7 +217,7 @@ IGL_INLINE void igl::signed_distance_pseudonormal(
     C.row(p) = c;
   }
 //  igl::AABB<MatrixXd,3> tree_P;
-//  MatrixXi J = VectorXi::LinSpaced(P.rows(),0,P.rows()-1);
+//  MatrixXi J = igl::LinSpaced<VectorXi >(P.rows(),0,P.rows()-1);
 //  tree_P.init(P,J);
 //  tree.squared_distance(V,F,tree_P,P,J,S,I,C);
 //# pragma omp parallel for if(np>1000)

+ 4 - 4
include/igl/slice.cpp

@@ -101,8 +101,8 @@ IGL_INLINE void igl::slice(
   assert(C.maxCoeff() < xn);
 
   // initialize row and col permutation vectors
-  Eigen::VectorXi rowIndexVec = Eigen::VectorXi::LinSpaced(xm,0,xm-1);
-  Eigen::VectorXi rowPermVec  = Eigen::VectorXi::LinSpaced(xm,0,xm-1);
+  Eigen::VectorXi rowIndexVec = igl::LinSpaced<Eigen::VectorXi >(xm,0,xm-1);
+  Eigen::VectorXi rowPermVec  = igl::LinSpaced<Eigen::VectorXi >(xm,0,xm-1);
   for(int i=0;i<ym;i++)
   {
     int pos = rowIndexVec.coeffRef(R(i));
@@ -115,8 +115,8 @@ IGL_INLINE void igl::slice(
   }
   Eigen::PermutationMatrix<Eigen::Dynamic,Eigen::Dynamic,int> rowPerm(rowIndexVec);
 
-  Eigen::VectorXi colIndexVec = Eigen::VectorXi::LinSpaced(xn,0,xn-1);
-  Eigen::VectorXi colPermVec =  Eigen::VectorXi::LinSpaced(xn,0,xn-1);
+  Eigen::VectorXi colIndexVec = igl::LinSpaced<Eigen::VectorXi >(xn,0,xn-1);
+  Eigen::VectorXi colPermVec =  igl::LinSpaced<Eigen::VectorXi >(xn,0,xn-1);
   for(int i=0;i<yn;i++)
   {
     int pos = colIndexVec.coeffRef(C(i));

+ 14 - 10
include/igl/slice_tets.cpp

@@ -6,9 +6,10 @@
 // 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/.
 #include "slice_tets.h"
-#include <igl/sort.h>
-#include <igl/cat.h>
-#include <igl/per_face_normals.h>
+#include "LinSpaced.h"
+#include "sort.h"
+#include "cat.h"
+#include "per_face_normals.h"
 #include <cassert>
 #include <algorithm>
 #include <vector>
@@ -150,7 +151,10 @@ IGL_INLINE void igl::slice_tets(
     G.resize(m,3);
     for(size_t c = 0;c<3;c++)
     {
-      G.col(c).setLinSpaced(m,0+c*m,(m-1)+c*m);
+      G.col(c) = 
+        igl::LinSpaced<
+        Eigen::Matrix<typename DerivedG::Scalar,Eigen::Dynamic,1> >
+        (m,0+c*m,(m-1)+c*m);
     }
   };
 
@@ -189,12 +193,12 @@ IGL_INLINE void igl::slice_tets(
     BC.reserve(m*4*2);
     BC.setFromTriplets(IJV.begin(),IJV.end());
     G.resize(2*m,3);
-    G.block(0,0,m,1) = VectorXI::LinSpaced(m,0+0*m,(m-1)+0*m);
-    G.block(0,1,m,1) = VectorXI::LinSpaced(m,0+1*m,(m-1)+1*m);
-    G.block(0,2,m,1) = VectorXI::LinSpaced(m,0+3*m,(m-1)+3*m);
-    G.block(m,0,m,1) = VectorXI::LinSpaced(m,0+0*m,(m-1)+0*m);
-    G.block(m,1,m,1) = VectorXI::LinSpaced(m,0+3*m,(m-1)+3*m);
-    G.block(m,2,m,1) = VectorXI::LinSpaced(m,0+2*m,(m-1)+2*m);
+    G.block(0,0,m,1) = igl::LinSpaced<VectorXI >(m,0+0*m,(m-1)+0*m);
+    G.block(0,1,m,1) = igl::LinSpaced<VectorXI >(m,0+1*m,(m-1)+1*m);
+    G.block(0,2,m,1) = igl::LinSpaced<VectorXI >(m,0+3*m,(m-1)+3*m);
+    G.block(m,0,m,1) = igl::LinSpaced<VectorXI >(m,0+0*m,(m-1)+0*m);
+    G.block(m,1,m,1) = igl::LinSpaced<VectorXI >(m,0+3*m,(m-1)+3*m);
+    G.block(m,2,m,1) = igl::LinSpaced<VectorXI >(m,0+2*m,(m-1)+2*m);
   };
 
   MatrixX3I G13,G31,G22;

+ 4 - 1
include/igl/sort_angles.cpp

@@ -6,6 +6,7 @@
 // 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/.
 #include "sort_angles.h"
+#include "LinSpaced.h"
 #include <algorithm>
 
 template <typename DerivedM, typename DerivedR>
@@ -17,7 +18,9 @@ IGL_INLINE void igl::sort_angles(
     assert(num_cols >= 2);
 
     R.resize(num_rows);
-    R.setLinSpaced(num_rows, 0, num_rows-1);
+    R = igl::LinSpaced<
+      Eigen::Matrix<typename DerivedR::Scalar, Eigen::Dynamic, 1> >
+      (num_rows, 0, num_rows-1);
 
     //              |
     // (pi/2, pi)   | (0, pi/2)

+ 4 - 3
include/igl/straighten_seams.cpp

@@ -6,6 +6,7 @@
 // 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/.
 #include "straighten_seams.h"
+#include "LinSpaced.h"
 #include "on_boundary.h"
 #include "sparse.h"
 #include "max.h"
@@ -84,7 +85,7 @@ IGL_INLINE void igl::straighten_seams(
   {
     SparseMatrix<bool> OEQR;
     sparse(
-      VectorXi::LinSpaced(OT.rows(),0,OT.rows()-1),
+      igl::LinSpaced<VectorXi >(OT.rows(),0,OT.rows()-1),
       OFMAP,
       Array<bool,Dynamic,1>::Ones(OT.rows(),1),
       OT.rows(),
@@ -139,7 +140,7 @@ IGL_INLINE void igl::straighten_seams(
   SparseMatrix<bool> VTOT;
   {
     Eigen::MatrixXi I = 
-      VectorXi::LinSpaced(OT.rows(),0,OT.rows()-1).replicate(1,2);
+      igl::LinSpaced<VectorXi >(OT.rows(),0,OT.rows()-1).replicate(1,2);
     sparse(
       OT,
       I,
@@ -288,7 +289,7 @@ IGL_INLINE void igl::straighten_seams(
             find(OEQIcT,Icc,II,IV);
             assert(II.size() == Ic.size() && 
               (II.array() ==
-              VectorXi::LinSpaced(Ic.size(),0,Ic.size()-1).array()).all());
+              igl::LinSpaced<VectorXi >(Ic.size(),0,Ic.size()-1).array()).all());
             assert(Icc.size() == Ic.size());
             const int cc = C(Icc(0));
             Eigen::VectorXi CIcc;

+ 2 - 1
include/igl/swept_volume_bounding_box.cpp

@@ -6,6 +6,7 @@
 // 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/.
 #include "swept_volume_bounding_box.h"
+#include "LinSpaced.h"
 
 IGL_INLINE void igl::swept_volume_bounding_box(
   const size_t & n,
@@ -15,7 +16,7 @@ IGL_INLINE void igl::swept_volume_bounding_box(
 {
   using namespace Eigen;
   box.setEmpty();
-  const VectorXd t = VectorXd::LinSpaced(steps,0,1);
+  const VectorXd t = igl::LinSpaced<VectorXd >(steps,0,1);
   // Find extent over all time steps
   for(int ti = 0;ti<t.size();ti++)
   {

+ 2 - 1
include/igl/swept_volume_signed_distance.cpp

@@ -6,6 +6,7 @@
 // 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/.
 #include "swept_volume_signed_distance.h"
+#include "LinSpaced.h"
 #include "flood_fill.h"
 #include "signed_distance.h"
 #include "AABB.h"
@@ -32,7 +33,7 @@ IGL_INLINE void igl::swept_volume_signed_distance(
   using namespace igl;
   using namespace Eigen;
   S = S0;
-  const VectorXd t = VectorXd::LinSpaced(steps,0,1);
+  const VectorXd t = igl::LinSpaced<VectorXd >(steps,0,1);
   const bool finite_iso = isfinite(isolevel);
   const double extension = (finite_iso ? isolevel : 0) + sqrt(3.0)*h;
   Eigen::AlignedBox3d box(