From 21d9d8aa0cabb393225cc2295baf9b4ab7ae3822 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Mon, 3 Sep 2012 19:25:27 +0000 Subject: [PATCH] Print ordering with multiple entries per line for more compact printout --- gtsam/nonlinear/Ordering.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gtsam/nonlinear/Ordering.cpp b/gtsam/nonlinear/Ordering.cpp index 9f99948a4..b445af506 100644 --- a/gtsam/nonlinear/Ordering.cpp +++ b/gtsam/nonlinear/Ordering.cpp @@ -44,10 +44,23 @@ void Ordering::print(const string& str, const KeyFormatter& keyFormatter) const cout << str; // Print ordering in index order Ordering::InvertedMap inverted = this->invert(); - cout << "key (zero-based order)\n"; + // Print the ordering with varsPerLine ordering entries printed on each line, + // for compactness. + static const size_t varsPerLine = 10; + bool endedOnNewline = false; BOOST_FOREACH(const Ordering::InvertedMap::value_type& index_key, inverted) { - cout << keyFormatter(index_key.second) << " (" << index_key.first << ")\n"; + if(index_key.first % varsPerLine != 0) + cout << ", "; + cout << index_key.first << ":" << keyFormatter(index_key.second); + if(index_key.first % varsPerLine == varsPerLine - 1) { + cout << "\n"; + endedOnNewline = true; + } else { + endedOnNewline = false; + } } + if(!endedOnNewline) + cout << "\n"; cout.flush(); }