diff --git a/gtsam_unstable/base/tests/testBAD.cpp b/gtsam_unstable/base/tests/testBAD.cpp index 0bbd02895..481efc2ed 100644 --- a/gtsam_unstable/base/tests/testBAD.cpp +++ b/gtsam_unstable/base/tests/testBAD.cpp @@ -310,6 +310,24 @@ private: boost::shared_ptr > root_; }; +// http://stackoverflow.com/questions/16260445/boost-bind-to-operator +template +struct apply_compose { + typedef T result_type; + T operator()(const T& x, const T& y, boost::optional H1, + boost::optional H2) const { + return x.compose(y, H1, H2); + } +}; + +/// Construct a product expression, assumes T::compose(T) -> T +template +Expression operator*(const Expression& expression1, + const Expression& expression2) { + return Expression(boost::bind(apply_compose(), _1, _2, _3, _4), + expression1, expression2); +} + // http://stackoverflow.com/questions/16260445/boost-bind-to-operator template struct apply_product { @@ -321,9 +339,11 @@ struct apply_product { /// Construct a product expression, assumes E1 * E2 -> E1 template -Expression operator*(const Expression& expression1, const Expression& expression2) { +Expression operator*(const Expression& expression1, + const Expression& expression2) { using namespace boost; - return Expression(boost::bind(apply_product(),_1,_2),expression1, expression2); + return Expression(boost::bind(apply_product(), _1, _2), + expression1, expression2); } //----------------------------------------------------------------------------- @@ -467,10 +487,17 @@ TEST(BAD, test) { /* ************************************************************************* */ +TEST(BAD, compose) { + Expression R1(1), R2(2); +// Expression R3 = R1 * R2; +} + +/* ************************************************************************* */ + TEST(BAD, rotate) { Expression R(1); Expression p(2); - // fails because optional derivatives can't be delivered by the operator + // fails because optional derivatives can't be delivered by the operator*() // Need a convention for products like these. "act" ? // Expression q = R * p; }