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:
Sameer Agarwal
2012-05-06 21:05:28 -07:00
parent f8bd7fa9aa
commit 82f4b88c34
16 changed files with 316 additions and 93 deletions
+13
View File
@@ -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