Add Program::ToString() to aid debugging.
Change-Id: I0ab37ed2fe0947ca87a152919d4e7dc9b56dedc6
diff --git a/internal/ceres/program.cc b/internal/ceres/program.cc
index 4dfb3a1..04248e7 100644
--- a/internal/ceres/program.cc
+++ b/internal/ceres/program.cc
@@ -216,5 +216,16 @@
return max_residuals;
}
+string Program::ToString() const {
+ string ret = "Program dump\n";
+ ret += StringPrintf("Number of parameter blocks: %d\n", NumParameterBlocks());
+ ret += StringPrintf("Number of parameters: %d\n", NumParameters());
+ ret += "Parameters:\n";
+ for (int i = 0; i < parameter_blocks_.size(); ++i) {
+ ret += StringPrintf("%d: %s\n",
+ i, parameter_blocks_[i]->ToString().c_str());
+ }
+}
+
} // namespace internal
} // namespace ceres