From 6e6bb6b51330dde4dfea40596d7679b99d44cce1 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Wed, 25 Jan 2023 18:32:50 -0800 Subject: [PATCH] Fixed arguments in constructors --- gtsam/linear/tests/testJacobianFactor.cpp | 22 +++++++------------ .../linear/tests/testLinearEquality.cpp | 11 +++++----- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/gtsam/linear/tests/testJacobianFactor.cpp b/gtsam/linear/tests/testJacobianFactor.cpp index 52d85bd41..9597b8f53 100644 --- a/gtsam/linear/tests/testJacobianFactor.cpp +++ b/gtsam/linear/tests/testJacobianFactor.cpp @@ -35,8 +35,8 @@ using Dims = std::vector; // For constructing block matrices namespace { namespace simple { // Terms we'll use - const vector > terms{ - {5, I_3x3}, {10, 2 * I_3x3}, {15, 3 * I_3x3}}; + using Terms = vector >; + const Terms terms{{5, I_3x3}, {10, 2 * I_3x3}, {15, 3 * I_3x3}}; // RHS and sigmas const Vector b = Vector3(1., 2., 3.); @@ -53,8 +53,7 @@ TEST(JacobianFactor, constructors_and_accessors) // Test for using different numbers of terms { // b vector only constructor - JacobianFactor expected( - std::vector(terms.begin(), terms.begin()), b); + JacobianFactor expected(Terms{}, b); JacobianFactor actual(b); EXPECT(assert_equal(expected, actual)); EXPECT(assert_equal(b, expected.getb())); @@ -64,8 +63,7 @@ TEST(JacobianFactor, constructors_and_accessors) } { // One term constructor - JacobianFactor expected( - std::vector(terms.begin(), terms.begin() + 1), b, noise); + JacobianFactor expected(Terms{terms[0]}, b, noise); JacobianFactor actual(terms[0].first, terms[0].second, b, noise); EXPECT(assert_equal(expected, actual)); LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back()); @@ -77,8 +75,7 @@ TEST(JacobianFactor, constructors_and_accessors) } { // Two term constructor - JacobianFactor expected( - std::vector(terms.begin(), terms.begin() + 2), b, noise); + JacobianFactor expected(Terms{terms[0], terms[1]}, b, noise); JacobianFactor actual(terms[0].first, terms[0].second, terms[1].first, terms[1].second, b, noise); EXPECT(assert_equal(expected, actual)); @@ -91,8 +88,7 @@ TEST(JacobianFactor, constructors_and_accessors) } { // Three term constructor - JacobianFactor expected( - std::vector(terms.begin(), terms.begin() + 3), b, noise); + JacobianFactor expected(Terms{terms[0], terms[1], terms[2]}, b, noise); JacobianFactor actual(terms[0].first, terms[0].second, terms[1].first, terms[1].second, terms[2].first, terms[2].second, b, noise); EXPECT(assert_equal(expected, actual)); @@ -105,8 +101,7 @@ TEST(JacobianFactor, constructors_and_accessors) } { // Test three-term constructor with std::map - JacobianFactor expected( - std::vector(terms.begin(), terms.begin() + 3), b, noise); + JacobianFactor expected(Terms{terms[0], terms[1], terms[2]}, b, noise); map mapTerms; // note order of insertion plays no role: order will be determined by keys mapTerms.insert(terms[2]); @@ -123,8 +118,7 @@ TEST(JacobianFactor, constructors_and_accessors) } { // VerticalBlockMatrix constructor - JacobianFactor expected( - std::vector(terms.begin(), terms.begin() + 3), b, noise); + JacobianFactor expected(Terms{terms[0], terms[1], terms[2]}, b, noise); VerticalBlockMatrix blockMatrix(Dims{3, 3, 3, 1}, 3); blockMatrix(0) = terms[0].second; blockMatrix(1) = terms[1].second; diff --git a/gtsam_unstable/linear/tests/testLinearEquality.cpp b/gtsam_unstable/linear/tests/testLinearEquality.cpp index 2f4d41ced..781ae26c1 100644 --- a/gtsam_unstable/linear/tests/testLinearEquality.cpp +++ b/gtsam_unstable/linear/tests/testLinearEquality.cpp @@ -29,8 +29,9 @@ GTSAM_CONCEPT_TESTABLE_INST(LinearEquality) namespace { namespace simple { // Terms we'll use -const vector > terms{ - make_pair(5, I_3x3), make_pair(10, 2 * I_3x3), make_pair(15, 3 * I_3x3)}; +using Terms = vector >; +const Terms terms{make_pair(5, I_3x3), make_pair(10, 2 * I_3x3), + make_pair(15, 3 * I_3x3)}; // RHS and sigmas const Vector b = (Vector(3) << 1., 2., 3.).finished(); @@ -45,7 +46,7 @@ TEST(LinearEquality, constructors_and_accessors) { // Test for using different numbers of terms { // One term constructor - LinearEquality expected(terms.begin(), terms.begin() + 1, b, 0); + LinearEquality expected(Terms(terms.begin(), terms.begin() + 1), b, 0); LinearEquality actual(terms[0].first, terms[0].second, b, 0); EXPECT(assert_equal(expected, actual)); LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back()); @@ -56,7 +57,7 @@ TEST(LinearEquality, constructors_and_accessors) { } { // Two term constructor - LinearEquality expected(terms.begin(), terms.begin() + 2, b, 0); + LinearEquality expected(Terms(terms.begin(), terms.begin() + 2), b, 0); LinearEquality actual(terms[0].first, terms[0].second, terms[1].first, terms[1].second, b, 0); EXPECT(assert_equal(expected, actual)); @@ -68,7 +69,7 @@ TEST(LinearEquality, constructors_and_accessors) { } { // Three term constructor - LinearEquality expected(terms.begin(), terms.begin() + 3, b, 0); + LinearEquality expected(Terms(terms.begin(), terms.begin() + 3), b, 0); LinearEquality actual(terms[0].first, terms[0].second, terms[1].first, terms[1].second, terms[2].first, terms[2].second, b, 0);