mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Extend support writing linear least squares problems to disk.
1. Make the mechanism for writing problems to disk, generic and controllable using an enum DumpType visible in the API. 2. Instead of single file containing protocol buffers, now matrices can be written in a matlab/octave friendly format. This is now the default. 3. The support for writing problems to disk is moved into linear_least_squares_problem.cc/h 4. SparseMatrix now has a ToTextFile virtual method which is implemented by each of its subclasses to write a (i,j,s) triplets. 5. Minor changes to simple_bundle_adjuster to enable logging at startup.
This commit is contained in:
@@ -179,6 +179,19 @@ AlignedMatrixRef DenseSparseMatrix::mutable_matrix() {
|
||||
return AlignedMatrixRef(m_.data(), m_.rows(), m_.cols());
|
||||
}
|
||||
|
||||
void DenseSparseMatrix::ToTextFile(FILE* file) const {
|
||||
CHECK_NOTNULL(file);
|
||||
const int active_rows =
|
||||
(has_diagonal_reserved_ && !has_diagonal_appended_)
|
||||
? (m_.rows() - m_.cols())
|
||||
: m_.rows();
|
||||
|
||||
for (int r = 0; r < active_rows; ++r) {
|
||||
for (int c = 0; c < m_.cols(); ++c) {
|
||||
fprintf(file, "% 10d % 10d %17f\n", r, c, m_(r, c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ceres
|
||||
|
||||
Reference in New Issue
Block a user