From d57e5d5c4580f65cd353a17a81d6edbd0ae83745 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sat, 12 Feb 2022 11:19:04 -0500 Subject: [PATCH] fix TBB ordering issue --- gtsam/linear/VectorValues.cpp | 7 +++++++ gtsam/linear/tests/testVectorValues.cpp | 1 + 2 files changed, 8 insertions(+) diff --git a/gtsam/linear/VectorValues.cpp b/gtsam/linear/VectorValues.cpp index bf1579eac..371a5b26d 100644 --- a/gtsam/linear/VectorValues.cpp +++ b/gtsam/linear/VectorValues.cpp @@ -393,7 +393,14 @@ namespace gtsam { ss << " \n \n"; // Print out all rows. +#ifdef GTSAM_USE_TBB + // TBB uses un-ordered map, so inefficiently order them: + std::map ordered; + for (const auto& kv : *this) ordered.emplace(kv); + for (const auto& kv : ordered) { +#else for (const auto& kv : *this) { +#endif ss << " "; ss << "" << keyFormatter(kv.first) << "" << kv.second.transpose() << ""; diff --git a/gtsam/linear/tests/testVectorValues.cpp b/gtsam/linear/tests/testVectorValues.cpp index 521cc2289..81b15b3e2 100644 --- a/gtsam/linear/tests/testVectorValues.cpp +++ b/gtsam/linear/tests/testVectorValues.cpp @@ -272,6 +272,7 @@ TEST(VectorValues, html) { "\n" ""; string actual = vv.html(); + cout << actual << endl; EXPECT(actual == expected); }