diff --git a/gtsam/base/ChartValue.h b/gtsam/base/ChartValue.h index 1ba51ff6a..a5028b0d3 100644 --- a/gtsam/base/ChartValue.h +++ b/gtsam/base/ChartValue.h @@ -42,20 +42,20 @@ namespace gtsam { -// ChartValue is derived from GenericValue and CHART so that CHART can be zero sized (as in DefaultChart) -// if the CHART is a member variable then it won't ever be zero sized. -template > -class ChartValue : public GenericValue, public CHART { - BOOST_CONCEPT_ASSERT((ChartConcept)); +// ChartValue is derived from GenericValue and Chart so that Chart can be zero sized (as in DefaultChart) +// if the Chart is a member variable then it won't ever be zero sized. +template > +class ChartValue : public GenericValue, public Chart { + BOOST_CONCEPT_ASSERT((ChartConcept)); public: typedef T type; - typedef CHART Chart; + typedef Chart_ Chart; public: ChartValue() : GenericValue(T()) {} ChartValue(const T& value) : GenericValue(value) {} template - ChartValue(const T& value, C chart_initializer) : GenericValue(value), CHART(chart_initializer) {} + ChartValue(const T& value, C chart_initializer) : GenericValue(value), Chart(chart_initializer) {} virtual ~ChartValue() {} @@ -96,7 +96,7 @@ class ChartValue : public GenericValue, public CHART { // Create a Value pointer copy of the result void* resultAsValuePlace = boost::singleton_pool::malloc(); - Value* resultAsValue = new(resultAsValuePlace) ChartValue(retractResult, static_cast(*this)); + Value* resultAsValue = new(resultAsValuePlace) ChartValue(retractResult, static_cast(*this)); // Return the pointer to the Value base class return resultAsValue; @@ -141,7 +141,7 @@ private: namespace traits { template -struct dimension > : public dimension {}; +struct dimension > : public dimension {}; } template diff --git a/gtsam/base/Manifold.h b/gtsam/base/Manifold.h index 0cac8cc6d..8f897c36d 100644 --- a/gtsam/base/Manifold.h +++ b/gtsam/base/Manifold.h @@ -181,12 +181,12 @@ struct ChartConcept { /** * Returns Retraction update of val_ */ - type retract_ret = C::retract(val_,vec_); + type retract_ret = C::retract(val_, vec_); /** * Returns local coordinates of another object */ - vec_ = C::local(val_,retract_ret); + vec_ = C::local(val_, retract_ret); // a way to get the dimension that is compatible with dynamically sized types dim_ = C::getDimension(val_); diff --git a/gtsam/base/numericalDerivative.h b/gtsam/base/numericalDerivative.h index 70edb64e6..9339c9c7b 100644 --- a/gtsam/base/numericalDerivative.h +++ b/gtsam/base/numericalDerivative.h @@ -124,7 +124,7 @@ Matrix numericalDerivative11(boost::function h, const X& x, ChartY chartY; // Bit of a hack for now to find number of rows - TangentY zeroY = chartY.local(hx,hx); + TangentY zeroY = chartY.local(hx, hx); size_t m = zeroY.size(); // get chart at x diff --git a/gtsam/nonlinear/Values-inl.h b/gtsam/nonlinear/Values-inl.h index 36bb60144..87b2a51cc 100644 --- a/gtsam/nonlinear/Values-inl.h +++ b/gtsam/nonlinear/Values-inl.h @@ -65,19 +65,19 @@ namespace gtsam { }; // partial specialized version for ValueType == Value template - struct ValuesCastHelper { + struct ValuesCastHelper { static CastedKeyValuePairType cast(KeyValuePairType key_value) { // Static cast because we already checked the type during filtering - // in this case the casted and keyvalue pair are essentially the same type (key,Value&) so perhaps this could be done with just a cast of the key_value? + // in this case the casted and keyvalue pair are essentially the same type (key, Value&) so perhaps this could be done with just a cast of the key_value? return CastedKeyValuePairType(key_value.key, key_value.value); } }; // partial specialized version for ValueType == Value template - struct ValuesCastHelper { + struct ValuesCastHelper { static CastedKeyValuePairType cast(KeyValuePairType key_value) { // Static cast because we already checked the type during filtering - // in this case the casted and keyvalue pair are essentially the same type (key,Value&) so perhaps this could be done with just a cast of the key_value? + // in this case the casted and keyvalue pair are essentially the same type (key, Value&) so perhaps this could be done with just a cast of the key_value? return CastedKeyValuePairType(key_value.key, key_value.value); } }; @@ -302,7 +302,7 @@ namespace gtsam { // overloaded insert with chart initializer template void Values::insert(Key j, const ValueType& val, ChartInit chart) { - insert(j, static_cast(ChartValue(val,chart))); + insert(j, static_cast(ChartValue(val, chart))); } // update with default chart @@ -318,7 +318,7 @@ namespace gtsam { // update with chart initializer, /todo: perhaps there is a way to init chart from old value... template void Values::update(Key j, const ValueType& val, ChartInit chart) { - update(j, static_cast(ChartValue(val,chart))); + update(j, static_cast(ChartValue(val, chart))); } } diff --git a/gtsam/nonlinear/Values.h b/gtsam/nonlinear/Values.h index 459277dd7..f6a8af3a1 100644 --- a/gtsam/nonlinear/Values.h +++ b/gtsam/nonlinear/Values.h @@ -393,7 +393,7 @@ namespace gtsam { // supplied \c filter function. template static bool filterHelper(const boost::function filter, const ConstKeyValuePair& key_value) { - BOOST_STATIC_ASSERT((!std::is_same::value)); + BOOST_STATIC_ASSERT((!std::is_same::value)); // Filter and check the type return filter(key_value.key) && (dynamic_cast*>(&key_value.value)); } diff --git a/gtsam/nonlinear/tests/testValues.cpp b/gtsam/nonlinear/tests/testValues.cpp index 17da8b08e..bfc156671 100644 --- a/gtsam/nonlinear/tests/testValues.cpp +++ b/gtsam/nonlinear/tests/testValues.cpp @@ -38,7 +38,7 @@ static double inf = std::numeric_limits::infinity(); using symbol_shorthand::X; using symbol_shorthand::L; -const Symbol key1('v',1), key2('v',2), key3('v',3), key4('v',4); +const Symbol key1('v', 1), key2('v', 2), key3('v', 3), key4('v', 4); class TestValueData { @@ -76,10 +76,10 @@ TEST( Values, equals1 ) Values expected; LieVector v((Vector(3) << 5.0, 6.0, 7.0)); - expected.insert(key1,v); + expected.insert(key1, v); Values actual; - actual.insert(key1,v); - CHECK(assert_equal(expected,actual)); + actual.insert(key1, v); + CHECK(assert_equal(expected, actual)); } /* ************************************************************************* */ @@ -269,7 +269,7 @@ TEST(Values, expmap_d) CHECK(config0.equals(config0)); Values poseconfig; - poseconfig.insert(key1, Pose2(1,2,3)); + poseconfig.insert(key1, Pose2(1, 2, 3)); poseconfig.insert(key2, Pose2(0.3, 0.4, 0.5)); CHECK(equal(config0, config0)); @@ -339,7 +339,7 @@ TEST(Values, update) Values expected; expected.insert(key1, LieVector((Vector(1) << -1.))); expected.insert(key2, LieVector((Vector(1) << -2.))); - CHECK(assert_equal(expected,config0)); + CHECK(assert_equal(expected, config0)); } /* ************************************************************************* */ @@ -419,9 +419,9 @@ TEST(Values, Symbol_filter) { Values values; values.insert(X(0), pose0); - values.insert(Symbol('y',1), pose1); + values.insert(Symbol('y', 1), pose1); values.insert(X(2), pose2); - values.insert(Symbol('y',3), pose3); + values.insert(Symbol('y', 3), pose3); int i = 0; BOOST_FOREACH(const Values::Filtered::KeyValuePair& key_value, values.filter(Symbol::ChrTest('y'))) { diff --git a/tests/testManifold.cpp b/tests/testManifold.cpp index b3d45ab19..55a5f5af0 100644 --- a/tests/testManifold.cpp +++ b/tests/testManifold.cpp @@ -67,8 +67,8 @@ TEST(Manifold, _dimension) { TEST(Manifold, DefaultChart) { DefaultChart chart1; - EXPECT(chart1.local(Point2(0, 0), Point2(1,0)) == Vector2(1, 0)); - EXPECT(chart1.retract(Point2(0, 0), Vector2(1,0)) == Point2(1, 0)); + EXPECT(chart1.local(Point2(0, 0), Point2(1, 0)) == Vector2(1, 0)); + EXPECT(chart1.retract(Point2(0, 0), Vector2(1, 0)) == Point2(1, 0)); Vector v2(2); v2 << 1, 0; @@ -79,7 +79,7 @@ TEST(Manifold, DefaultChart) { DefaultChart chart3; Vector v1(1); v1 << 1; - EXPECT(assert_equal(v1,chart3.local(0, 1))); + EXPECT(assert_equal(v1, chart3.local(0, 1))); EXPECT_DOUBLES_EQUAL(chart3.retract(0, v1), 1, 1e-9); // Dynamic does not work yet ! @@ -94,20 +94,20 @@ TEST(Manifold, DefaultChart) { Rot3 I = Rot3::identity(); Rot3 R = I.retract(v3); DefaultChart chart5; - EXPECT(assert_equal(v3,chart5.local(I, R))); + EXPECT(assert_equal(v3, chart5.local(I, R))); EXPECT(assert_equal(chart5.retract(I, v3), R)); // Check zero vector DefaultChart chart6; - EXPECT(assert_equal(zero(3),chart6.local(R, R))); + EXPECT(assert_equal(zero(3), chart6.local(R, R))); } /* ************************************************************************* */ // zero TEST(Manifold, _zero) { - EXPECT(assert_equal(Pose3(),traits::zero::value())); + EXPECT(assert_equal(Pose3(), traits::zero::value())); Cal3Bundler cal(0, 0, 0); - EXPECT(assert_equal(cal,traits::zero::value())); - EXPECT(assert_equal(Camera(Pose3(),cal),traits::zero::value())); + EXPECT(assert_equal(cal, traits::zero::value())); + EXPECT(assert_equal(Camera(Pose3(), cal), traits::zero::value())); } /* ************************************************************************* */ @@ -115,14 +115,14 @@ TEST(Manifold, _zero) { TEST(Manifold, Canonical) { Canonical chart1; - EXPECT(chart1.local(Point2(1,0))==Vector2(1,0)); - EXPECT(chart1.retract(Vector2(1,0))==Point2(1,0)); + EXPECT(chart1.local(Point2(1, 0))==Vector2(1, 0)); + EXPECT(chart1.retract(Vector2(1, 0))==Point2(1, 0)); Vector v2(2); v2 << 1, 0; Canonical chart2; - EXPECT(assert_equal(v2,chart2.local(Vector2(1,0)))); - EXPECT(chart2.retract(v2)==Vector2(1,0)); + EXPECT(assert_equal(v2, chart2.local(Vector2(1, 0)))); + EXPECT(chart2.retract(v2)==Vector2(1, 0)); Canonical chart3; Eigen::Matrix v1; @@ -134,29 +134,29 @@ TEST(Manifold, Canonical) { Point3 point(1, 2, 3); Vector v3(3); v3 << 1, 2, 3; - EXPECT(assert_equal(v3,chart4.local(point))); - EXPECT(assert_equal(chart4.retract(v3),point)); + EXPECT(assert_equal(v3, chart4.local(point))); + EXPECT(assert_equal(chart4.retract(v3), point)); Canonical chart5; Pose3 pose(Rot3::identity(), point); Vector v6(6); v6 << 0, 0, 0, 1, 2, 3; - EXPECT(assert_equal(v6,chart5.local(pose))); - EXPECT(assert_equal(chart5.retract(v6),pose)); + EXPECT(assert_equal(v6, chart5.local(pose))); + EXPECT(assert_equal(chart5.retract(v6), pose)); Canonical chart6; Cal3Bundler cal0(0, 0, 0); Camera camera(Pose3(), cal0); Vector z9 = Vector9::Zero(); - EXPECT(assert_equal(z9,chart6.local(camera))); - EXPECT(assert_equal(chart6.retract(z9),camera)); + EXPECT(assert_equal(z9, chart6.local(camera))); + EXPECT(assert_equal(chart6.retract(z9), camera)); Cal3Bundler cal; // Note !! Cal3Bundler() != zero::value() Camera camera2(pose, cal); Vector v9(9); v9 << 0, 0, 0, 1, 2, 3, 1, 0, 0; - EXPECT(assert_equal(v9,chart6.local(camera2))); - EXPECT(assert_equal(chart6.retract(v9),camera2)); + EXPECT(assert_equal(v9, chart6.local(camera2))); + EXPECT(assert_equal(chart6.retract(v9), camera2)); } /* ************************************************************************* */