diff --git a/gtsam/linear/SparseEigen.h b/gtsam/linear/SparseEigen.h index 35062c4fe..5ee67f6d9 100644 --- a/gtsam/linear/SparseEigen.h +++ b/gtsam/linear/SparseEigen.h @@ -32,8 +32,13 @@ namespace gtsam { typedef Eigen::SparseMatrix SpMat; +/// Constructs an Eigen-format SparseMatrix of a GaussianFactorGraph SpMat sparseJacobianEigen( const GaussianFactorGraph &gfg, const Ordering &ordering) { + // TODO(gerry): eliminate copy/pasta by making GaussianFactorGraph version + // more general, or by creating an Eigen::Triplet compatible wrapper for + // boost::tuple return type + // First find dimensions of each variable std::map dims; for (const boost::shared_ptr &factor : gfg) { @@ -111,36 +116,4 @@ SpMat sparseJacobianEigen(const GaussianFactorGraph &gfg) { return sparseJacobianEigen(gfg, Ordering(gfg.keys())); } -// /// obtain sparse matrix for eigen sparse solver -// std::pair obtainSparseMatrix( -// const GaussianFactorGraph &gfg, const Ordering &ordering) { -// gttic_(EigenOptimizer_obtainSparseMatrix); - -// // Get sparse entries of Jacobian [A|b] augmented with RHS b. -// auto entries = gfg.sparseJacobian(ordering); - -// gttic_(EigenOptimizer_convertSparse); -// // Convert boost tuples to Eigen triplets -// vector> triplets; -// triplets.reserve(entries.size()); -// size_t rows = 0, cols = 0; -// for (const auto &e : entries) { -// size_t temp_rows = e.get<0>(), temp_cols = e.get<1>(); -// triplets.emplace_back(temp_rows, temp_cols, e.get<2>()); -// rows = std::max(rows, temp_rows); -// cols = std::max(cols, temp_cols); -// } - -// // ...and make a sparse matrix with it. -// SpMat Ab(rows + 1, cols + 1); -// Ab.setFromTriplets(triplets.begin(), triplets.end()); -// Ab.makeCompressed(); -// gttoc_(EigenOptimizer_convertSparse); - -// gttoc_(EigenOptimizer_obtainSparseMatrix); - -// return make_pair(Ab.block(0, 0, rows + 1, cols), -// Ab.col(cols)); -// } - } // namespace gtsam