use standard function to check for empty string

release/4.3a0
Varun Agrawal 2021-01-25 16:22:09 -05:00
parent 5e8acf4378
commit ccd64fb08c
7 changed files with 10 additions and 9 deletions

View File

@ -72,10 +72,10 @@ namespace gtsam {
}; // \ Testable }; // \ Testable
inline void print(float v, const std::string& s = "") { inline void print(float v, const std::string& s = "") {
std::cout << (s == "" ? s : s + " ") << v << std::endl; std::cout << (s.empty() ? s : s + " ") << v << std::endl;
} }
inline void print(double v, const std::string& s = "") { inline void print(double v, const std::string& s = "") {
std::cout << (s == "" ? s : s + " ") << v << std::endl; std::cout << (s.empty() ? s : s + " ") << v << std::endl;
} }
/** Call equal on the object */ /** Call equal on the object */

View File

@ -167,7 +167,7 @@ gtsam::NonlinearFactor::shared_ptr CombinedImuFactor::clone() const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void CombinedImuFactor::print(const string& s, void CombinedImuFactor::print(const string& s,
const KeyFormatter& keyFormatter) const { const KeyFormatter& keyFormatter) const {
cout << (s == "" ? s : s + "\n") << "CombinedImuFactor(" cout << (s.empty() ? s : s + "\n") << "CombinedImuFactor("
<< keyFormatter(this->key1()) << "," << keyFormatter(this->key2()) << "," << keyFormatter(this->key1()) << "," << keyFormatter(this->key2()) << ","
<< keyFormatter(this->key3()) << "," << keyFormatter(this->key4()) << "," << keyFormatter(this->key3()) << "," << keyFormatter(this->key4()) << ","
<< keyFormatter(this->key5()) << "," << keyFormatter(this->key6()) << keyFormatter(this->key5()) << "," << keyFormatter(this->key6())

View File

@ -130,7 +130,7 @@ std::ostream& operator<<(std::ostream& os, const ImuFactor& f) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ImuFactor::print(const string& s, const KeyFormatter& keyFormatter) const { void ImuFactor::print(const string& s, const KeyFormatter& keyFormatter) const {
cout << (s == "" ? s : s + "\n") << "ImuFactor(" << keyFormatter(this->key1()) cout << (s.empty() ? s : s + "\n") << "ImuFactor(" << keyFormatter(this->key1())
<< "," << keyFormatter(this->key2()) << "," << keyFormatter(this->key3()) << "," << keyFormatter(this->key2()) << "," << keyFormatter(this->key3())
<< "," << keyFormatter(this->key4()) << "," << keyFormatter(this->key5()) << "," << keyFormatter(this->key4()) << "," << keyFormatter(this->key5())
<< ")\n"; << ")\n";
@ -226,7 +226,7 @@ std::ostream& operator<<(std::ostream& os, const ImuFactor2& f) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ImuFactor2::print(const string& s, void ImuFactor2::print(const string& s,
const KeyFormatter& keyFormatter) const { const KeyFormatter& keyFormatter) const {
cout << (s == "" ? s : s + "\n") << "ImuFactor2(" cout << (s.empty() ? s : s + "\n") << "ImuFactor2("
<< keyFormatter(this->key1()) << "," << keyFormatter(this->key2()) << "," << keyFormatter(this->key1()) << "," << keyFormatter(this->key2()) << ","
<< keyFormatter(this->key3()) << ")\n"; << keyFormatter(this->key3()) << ")\n";
cout << *this << endl; cout << *this << endl;

View File

@ -26,7 +26,7 @@ using namespace std;
namespace gtsam { namespace gtsam {
void PreintegratedRotationParams::print(const string& s) const { void PreintegratedRotationParams::print(const string& s) const {
cout << (s == "" ? s : s + "\n") << endl; cout << (s.empty() ? s : s + "\n") << endl;
cout << "gyroscopeCovariance:\n[\n" << gyroscopeCovariance << "\n]" << endl; cout << "gyroscopeCovariance:\n[\n" << gyroscopeCovariance << "\n]" << endl;
if (omegaCoriolis) if (omegaCoriolis)
cout << "omegaCoriolis = (" << omegaCoriolis->transpose() << ")" << endl; cout << "omegaCoriolis = (" << omegaCoriolis->transpose() << ")" << endl;

View File

@ -46,7 +46,7 @@ ostream& operator<<(ostream& os, const PreintegrationBase& pim) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void PreintegrationBase::print(const string& s) const { void PreintegrationBase::print(const string& s) const {
cout << (s == "" ? s : s + "\n") << *this << endl; cout << (s.empty() ? s : s + "\n") << *this << endl;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -75,7 +75,7 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
void Values::print(const string& str, const KeyFormatter& keyFormatter) const { void Values::print(const string& str, const KeyFormatter& keyFormatter) const {
cout << str << (str == "" ? "" : "\n"); cout << str << (str.empty() ? "" : "\n");
cout << "Values with " << size() << " values:\n"; cout << "Values with " << size() << " values:\n";
for(const_iterator key_value = begin(); key_value != end(); ++key_value) { for(const_iterator key_value = begin(); key_value != end(); ++key_value) {
cout << "Value " << keyFormatter(key_value->key) << ": "; cout << "Value " << keyFormatter(key_value->key) << ": ";

View File

@ -91,7 +91,8 @@ struct GTSAM_EXPORT ShonanAveragingParameters {
bool getCertifyOptimality() const { return certifyOptimality; } bool getCertifyOptimality() const { return certifyOptimality; }
/// Print the parameters and flags used for rotation averaging. /// Print the parameters and flags used for rotation averaging.
void print() const { void print(const std::string &s = "") const {
std::cout << (s.empty() ? s : s + " ");
std::cout << " ShonanAveragingParameters: " << std::endl; std::cout << " ShonanAveragingParameters: " << std::endl;
std::cout << " alpha: " << alpha << std::endl; std::cout << " alpha: " << alpha << std::endl;
std::cout << " beta: " << beta << std::endl; std::cout << " beta: " << beta << std::endl;