Merge pull request #1030 from borglab/fix/minor-fg-print-issue

release/4.3a0
Varun Agrawal 2022-01-12 11:43:29 -05:00 committed by GitHub
commit 7cc3eb844b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -54,9 +54,14 @@ void NonlinearFactorGraph::print(const std::string& str, const KeyFormatter& key
for (size_t i = 0; i < factors_.size(); i++) { for (size_t i = 0; i < factors_.size(); i++) {
stringstream ss; stringstream ss;
ss << "Factor " << i << ": "; ss << "Factor " << i << ": ";
if (factors_[i] != nullptr) factors_[i]->print(ss.str(), keyFormatter); if (factors_[i] != nullptr) {
cout << endl; factors_[i]->print(ss.str(), keyFormatter);
cout << "\n";
} else {
cout << ss.str() << "nullptr\n";
}
} }
std::cout.flush();
} }
/* ************************************************************************* */ /* ************************************************************************* */
@ -80,8 +85,9 @@ void NonlinearFactorGraph::printErrors(const Values& values, const std::string&
factor->print(ss.str(), keyFormatter); factor->print(ss.str(), keyFormatter);
cout << "error = " << errorValue << "\n"; cout << "error = " << errorValue << "\n";
} }
cout << endl; // only one "endl" at end might be faster, \n for each factor cout << "\n";
} }
std::cout.flush();
} }
/* ************************************************************************* */ /* ************************************************************************* */