inline void buildSparseMatrix(Matrix3xd const & pts, SparseMatrix<double> & sparse) { const int m = pts.cols(); const int numNonZero = 3*m; sparse.resize(m, numNonZero); sparse.reserve(VectorXi::Constant(numNonZero, 1)); int j = 0; for (int i = 0 ; i < m ; i++) { for (int k = 0 ; k < 3 ; k++) { sparse.insert(i, j) = pts(j); j++; } } }
inline void buildSparseMatrix(Matrix3xd const & pts, SparseMatrix<double> & sparse) { typedef SparseMatrix<double>::Index SparseIndex; const SparseIndex m = static_cast<SparseIndex>(pts.cols()); const SparseIndex numNonZero = 3*m; sparse.resize(m, numNonZero); sparse.reserve(VectorXi::Constant(numNonZero, 1)); SparseIndex j = 0; for (SparseIndex i = 0 ; i < m ; i++) { for (SparseIndex k = 0 ; k < 3 ; k++) { sparse.insert(i, j) = pts(j); j++; } } }