Fixed arguments in constructors
parent
e5964736d1
commit
6e6bb6b513
|
@ -35,8 +35,8 @@ using Dims = std::vector<Eigen::Index>; // For constructing block matrices
|
||||||
namespace {
|
namespace {
|
||||||
namespace simple {
|
namespace simple {
|
||||||
// Terms we'll use
|
// Terms we'll use
|
||||||
const vector<pair<Key, Matrix> > terms{
|
using Terms = vector<pair<Key, Matrix> >;
|
||||||
{5, I_3x3}, {10, 2 * I_3x3}, {15, 3 * I_3x3}};
|
const Terms terms{{5, I_3x3}, {10, 2 * I_3x3}, {15, 3 * I_3x3}};
|
||||||
|
|
||||||
// RHS and sigmas
|
// RHS and sigmas
|
||||||
const Vector b = Vector3(1., 2., 3.);
|
const Vector b = Vector3(1., 2., 3.);
|
||||||
|
@ -53,8 +53,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
// Test for using different numbers of terms
|
// Test for using different numbers of terms
|
||||||
{
|
{
|
||||||
// b vector only constructor
|
// b vector only constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(Terms{}, b);
|
||||||
std::vector(terms.begin(), terms.begin()), b);
|
|
||||||
JacobianFactor actual(b);
|
JacobianFactor actual(b);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
EXPECT(assert_equal(b, expected.getb()));
|
EXPECT(assert_equal(b, expected.getb()));
|
||||||
|
@ -64,8 +63,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// One term constructor
|
// One term constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(Terms{terms[0]}, b, noise);
|
||||||
std::vector(terms.begin(), terms.begin() + 1), b, noise);
|
|
||||||
JacobianFactor actual(terms[0].first, terms[0].second, b, noise);
|
JacobianFactor actual(terms[0].first, terms[0].second, b, noise);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
||||||
|
@ -77,8 +75,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Two term constructor
|
// Two term constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(Terms{terms[0], terms[1]}, b, noise);
|
||||||
std::vector(terms.begin(), terms.begin() + 2), b, noise);
|
|
||||||
JacobianFactor actual(terms[0].first, terms[0].second,
|
JacobianFactor actual(terms[0].first, terms[0].second,
|
||||||
terms[1].first, terms[1].second, b, noise);
|
terms[1].first, terms[1].second, b, noise);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
|
@ -91,8 +88,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Three term constructor
|
// Three term constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(Terms{terms[0], terms[1], terms[2]}, b, noise);
|
||||||
std::vector(terms.begin(), terms.begin() + 3), b, noise);
|
|
||||||
JacobianFactor actual(terms[0].first, terms[0].second,
|
JacobianFactor actual(terms[0].first, terms[0].second,
|
||||||
terms[1].first, terms[1].second, terms[2].first, terms[2].second, b, noise);
|
terms[1].first, terms[1].second, terms[2].first, terms[2].second, b, noise);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
|
@ -105,8 +101,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Test three-term constructor with std::map
|
// Test three-term constructor with std::map
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(Terms{terms[0], terms[1], terms[2]}, b, noise);
|
||||||
std::vector(terms.begin(), terms.begin() + 3), b, noise);
|
|
||||||
map<Key,Matrix> mapTerms;
|
map<Key,Matrix> mapTerms;
|
||||||
// note order of insertion plays no role: order will be determined by keys
|
// note order of insertion plays no role: order will be determined by keys
|
||||||
mapTerms.insert(terms[2]);
|
mapTerms.insert(terms[2]);
|
||||||
|
@ -123,8 +118,7 @@ TEST(JacobianFactor, constructors_and_accessors)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// VerticalBlockMatrix constructor
|
// VerticalBlockMatrix constructor
|
||||||
JacobianFactor expected(
|
JacobianFactor expected(Terms{terms[0], terms[1], terms[2]}, b, noise);
|
||||||
std::vector(terms.begin(), terms.begin() + 3), b, noise);
|
|
||||||
VerticalBlockMatrix blockMatrix(Dims{3, 3, 3, 1}, 3);
|
VerticalBlockMatrix blockMatrix(Dims{3, 3, 3, 1}, 3);
|
||||||
blockMatrix(0) = terms[0].second;
|
blockMatrix(0) = terms[0].second;
|
||||||
blockMatrix(1) = terms[1].second;
|
blockMatrix(1) = terms[1].second;
|
||||||
|
|
|
@ -29,8 +29,9 @@ GTSAM_CONCEPT_TESTABLE_INST(LinearEquality)
|
||||||
namespace {
|
namespace {
|
||||||
namespace simple {
|
namespace simple {
|
||||||
// Terms we'll use
|
// Terms we'll use
|
||||||
const vector<pair<Key, Matrix> > terms{
|
using Terms = vector<pair<Key, Matrix> >;
|
||||||
make_pair(5, I_3x3), make_pair(10, 2 * I_3x3), make_pair(15, 3 * I_3x3)};
|
const Terms terms{make_pair(5, I_3x3), make_pair(10, 2 * I_3x3),
|
||||||
|
make_pair(15, 3 * I_3x3)};
|
||||||
|
|
||||||
// RHS and sigmas
|
// RHS and sigmas
|
||||||
const Vector b = (Vector(3) << 1., 2., 3.).finished();
|
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
|
// Test for using different numbers of terms
|
||||||
{
|
{
|
||||||
// One term constructor
|
// 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);
|
LinearEquality actual(terms[0].first, terms[0].second, b, 0);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
LONGS_EQUAL((long)terms[0].first, (long)actual.keys().back());
|
||||||
|
@ -56,7 +57,7 @@ TEST(LinearEquality, constructors_and_accessors) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Two term constructor
|
// 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,
|
LinearEquality actual(terms[0].first, terms[0].second, terms[1].first,
|
||||||
terms[1].second, b, 0);
|
terms[1].second, b, 0);
|
||||||
EXPECT(assert_equal(expected, actual));
|
EXPECT(assert_equal(expected, actual));
|
||||||
|
@ -68,7 +69,7 @@ TEST(LinearEquality, constructors_and_accessors) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Three term constructor
|
// 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,
|
LinearEquality actual(terms[0].first, terms[0].second, terms[1].first,
|
||||||
terms[1].second, terms[2].first, terms[2].second, b,
|
terms[1].second, terms[2].first, terms[2].second, b,
|
||||||
0);
|
0);
|
||||||
|
|
Loading…
Reference in New Issue