Fixed the member function with very ugly syntax

release/4.3a0
Paul Furgale 2014-09-30 23:13:07 +02:00
parent c68c2d2dac
commit 837b2a6bc0
3 changed files with 13 additions and 11 deletions

View File

@ -26,6 +26,8 @@ namespace gtsam {
template<typename T> template<typename T>
class Expression; class Expression;
template<typename T, typename E1, typename E2>
class MethodExpression;
/** /**
* Expression node. The superclass for objects that do the heavy lifting * Expression node. The superclass for objects that do the heavy lifting
@ -218,8 +220,8 @@ private:
expression1_(e1.root()), expression2_(e2.root()), f_(f) { expression1_(e1.root()), expression2_(e2.root()), f_(f) {
} }
friend class Expression<T> ; friend class Expression<T>;
public:
/// Combine Jacobians /// Combine Jacobians
static void combine(const Matrix& H1, const Matrix& H2, static void combine(const Matrix& H1, const Matrix& H2,
const JacobianMap& terms1, const JacobianMap& terms2, const JacobianMap& terms1, const JacobianMap& terms2,
@ -288,9 +290,9 @@ public:
typedef std::map<Key, Matrix> JacobianMap; typedef std::map<Key, Matrix> JacobianMap;
typedef boost::function< typedef
T(const E1*, const E2&, boost::optional<Matrix&>, T (E1::*method)(const E2&, boost::optional<Matrix&>,
boost::optional<Matrix&>)> method; boost::optional<Matrix&>) const;
private: private:
@ -326,11 +328,11 @@ public:
if (jacobians) { if (jacobians) {
JacobianMap terms1, terms2; JacobianMap terms1, terms2;
Matrix H1, H2; Matrix H1, H2;
val = f_(expression1_->value(values, terms1), val = (expression1_->value(values, terms1).*(f_))(
expression2_->value(values, terms2), H1, H2); expression2_->value(values, terms2), H1, H2);
BinaryExpression<T, E1, E2>::combine(H1, H2, terms1, terms2, *jacobians); BinaryExpression<T, E1, E2>::combine(H1, H2, terms1, terms2, *jacobians);
} else { } else {
val = f_(expression1_->value(values), expression2_->value(values), val = (expression1_->value(values).*(f_))(expression2_->value(values),
boost::none, boost::none); boost::none, boost::none);
} }
return val; return val;

View File

@ -63,7 +63,7 @@ public:
typename MethodExpression<T, E1, E2>::method f, typename MethodExpression<T, E1, E2>::method f,
const Expression<E2>& expression2) { const Expression<E2>& expression2) {
// TODO Assert that root of expressions 1 and 2 are not null. // TODO Assert that root of expressions 1 and 2 are not null.
root_.reset(new MethodExpression<T, E1, E2>(f, expression1, expression2)); root_.reset(new MethodExpression<T, E1, E2>(expression1, f, expression2));
} }
/// Return keys that play in this expression /// Return keys that play in this expression

View File

@ -7,7 +7,7 @@
* See LICENSE for the license information * See LICENSE for the license information
* -------------------------------------------------------------------------- */ * -------------------------------1------------------------------------------- */
/** /**
* @file testExpression.cpp * @file testExpression.cpp
@ -60,8 +60,8 @@ TEST(BAD, test) {
// Create expression tree // Create expression tree
// MethodExpression<Point3,Pose3,Point3>::method m = &Pose3::transform_to; // MethodExpression<Point3,Pose3,Point3>::method m = &Pose3::transform_to;
// MethodExpression<Point3,Pose3,Point3> methodExpression(x, &Pose3::transform_to, p); // MethodExpression<Point3,Pose3,Point3> methodExpression(x, &Pose3::transform_to, p);
// Expression<Point3> p_cam(x, &Pose3::transform_to, p); Expression<Point3> p_cam(x, &Pose3::transform_to, p);
Expression<Point3> p_cam(transformTo, x, p); //Expression<Point3> p_cam(transformTo, x, p);
Expression<Point2> projection(project, p_cam); Expression<Point2> projection(project, p_cam);
Expression<Point2> uv_hat(uncalibrate<Cal3_S2>, K, projection); Expression<Point2> uv_hat(uncalibrate<Cal3_S2>, K, projection);