move meta functions to Expression class scope
parent
3bce234403
commit
a99aaf892c
|
@ -537,7 +537,7 @@ struct FunctionalNode {
|
||||||
template<class T, class A1>
|
template<class T, class A1>
|
||||||
class UnaryExpression: public ExpressionNode<T> {
|
class UnaryExpression: public ExpressionNode<T> {
|
||||||
|
|
||||||
typedef typename UnaryFunction<T,A1>::type Function;
|
typedef typename Expression<T>::template UnaryFunction<A1>::type Function;
|
||||||
Function function_;
|
Function function_;
|
||||||
boost::shared_ptr<ExpressionNode<A1> > expression1_;
|
boost::shared_ptr<ExpressionNode<A1> > expression1_;
|
||||||
|
|
||||||
|
@ -679,7 +679,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef typename BinaryFunction<T,A1,A2>::type Function;
|
typedef typename Expression<T>::template BinaryFunction<A1,A2>::type Function;
|
||||||
Function function_;
|
Function function_;
|
||||||
|
|
||||||
/// Constructor with a ternary function f, and three input arguments
|
/// Constructor with a ternary function f, and three input arguments
|
||||||
|
@ -729,7 +729,7 @@ class TernaryExpression: public FunctionalNode<T, boost::mpl::vector<A1, A2, A3>
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef typename TernaryFunction<T,A1,A2,A3>::type Function;
|
typedef typename Expression<T>::template TernaryFunction<A1,A2,A3>::type Function;
|
||||||
Function function_;
|
Function function_;
|
||||||
|
|
||||||
/// Constructor with a ternary function f, and three input arguments
|
/// Constructor with a ternary function f, and three input arguments
|
||||||
|
@ -817,7 +817,7 @@ Expression<T>::Expression(const Expression<A>& expression,
|
||||||
/// Construct a unary function expression
|
/// Construct a unary function expression
|
||||||
template<typename T>
|
template<typename T>
|
||||||
template<typename A>
|
template<typename A>
|
||||||
Expression<T>::Expression(typename UnaryFunction<T, A>::type function,
|
Expression<T>::Expression(typename UnaryFunction<A>::type function,
|
||||||
const Expression<A>& expression) :
|
const Expression<A>& expression) :
|
||||||
root_(new UnaryExpression<T, A>(function, expression)) {
|
root_(new UnaryExpression<T, A>(function, expression)) {
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,7 @@ Expression<T>::Expression(const Expression<A1>& expression1,
|
||||||
/// Construct a binary function expression
|
/// Construct a binary function expression
|
||||||
template<typename T>
|
template<typename T>
|
||||||
template<typename A1, typename A2>
|
template<typename A1, typename A2>
|
||||||
Expression<T>::Expression(typename BinaryFunction<T, A1, A2>::type function,
|
Expression<T>::Expression(typename BinaryFunction<A1, A2>::type function,
|
||||||
const Expression<A1>& expression1, const Expression<A2>& expression2) :
|
const Expression<A1>& expression1, const Expression<A2>& expression2) :
|
||||||
root_(new BinaryExpression<T, A1, A2>(function, expression1, expression2)) {
|
root_(new BinaryExpression<T, A1, A2>(function, expression1, expression2)) {
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ Expression<T>::Expression(const Expression<A1>& expression1,
|
||||||
template<typename T>
|
template<typename T>
|
||||||
template<typename A1, typename A2, typename A3>
|
template<typename A1, typename A2, typename A3>
|
||||||
Expression<T>::Expression(
|
Expression<T>::Expression(
|
||||||
typename TernaryFunction<T, A1, A2, A3>::type function,
|
typename TernaryFunction<A1, A2, A3>::type function,
|
||||||
const Expression<A1>& expression1, const Expression<A2>& expression2,
|
const Expression<A1>& expression1, const Expression<A2>& expression2,
|
||||||
const Expression<A3>& expression3) :
|
const Expression<A3>& expression3) :
|
||||||
root_(
|
root_(
|
||||||
|
|
|
@ -43,30 +43,6 @@ template<typename T> class ExpressionFactor;
|
||||||
// For clarity, it is forward declared here but implemented at the end of this header.
|
// For clarity, it is forward declared here but implemented at the end of this header.
|
||||||
class JacobianMap;
|
class JacobianMap;
|
||||||
|
|
||||||
// Expressions wrap trees of functions that can evaluate their own derivatives.
|
|
||||||
// The meta-functions below provide a handy to specify the type of those functions
|
|
||||||
template<class T, class A1>
|
|
||||||
struct UnaryFunction {
|
|
||||||
typedef boost::function<
|
|
||||||
T(const A1&, typename MakeOptionalJacobian<T, A1>::type)> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, class A1, class A2>
|
|
||||||
struct BinaryFunction {
|
|
||||||
typedef boost::function<
|
|
||||||
T(const A1&, const A2&, typename MakeOptionalJacobian<T, A1>::type,
|
|
||||||
typename MakeOptionalJacobian<T, A2>::type)> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, class A1, class A2, class A3>
|
|
||||||
struct TernaryFunction {
|
|
||||||
typedef boost::function<
|
|
||||||
T(const A1&, const A2&, const A3&,
|
|
||||||
typename MakeOptionalJacobian<T, A1>::type,
|
|
||||||
typename MakeOptionalJacobian<T, A2>::type,
|
|
||||||
typename MakeOptionalJacobian<T, A3>::type)> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Storage type for the execution trace.
|
/// Storage type for the execution trace.
|
||||||
/// It enforces the proper alignment in a portable way.
|
/// It enforces the proper alignment in a portable way.
|
||||||
/// Provide a traceSize() sized array of this type to traceExecution as traceStorage.
|
/// Provide a traceSize() sized array of this type to traceExecution as traceStorage.
|
||||||
|
@ -91,6 +67,30 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Expressions wrap trees of functions that can evaluate their own derivatives.
|
||||||
|
// The meta-functions below provide a handy to specify the type of those functions
|
||||||
|
template<class A1>
|
||||||
|
struct UnaryFunction {
|
||||||
|
typedef boost::function<
|
||||||
|
T(const A1&, typename MakeOptionalJacobian<T, A1>::type)> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class A1, class A2>
|
||||||
|
struct BinaryFunction {
|
||||||
|
typedef boost::function<
|
||||||
|
T(const A1&, const A2&, typename MakeOptionalJacobian<T, A1>::type,
|
||||||
|
typename MakeOptionalJacobian<T, A2>::type)> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class A1, class A2, class A3>
|
||||||
|
struct TernaryFunction {
|
||||||
|
typedef boost::function<
|
||||||
|
T(const A1&, const A2&, const A3&,
|
||||||
|
typename MakeOptionalJacobian<T, A1>::type,
|
||||||
|
typename MakeOptionalJacobian<T, A2>::type,
|
||||||
|
typename MakeOptionalJacobian<T, A3>::type)> type;
|
||||||
|
};
|
||||||
|
|
||||||
/// Print
|
/// Print
|
||||||
void print(const std::string& s) const;
|
void print(const std::string& s) const;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public:
|
||||||
|
|
||||||
/// Construct a unary function expression
|
/// Construct a unary function expression
|
||||||
template<typename A>
|
template<typename A>
|
||||||
Expression(typename UnaryFunction<T, A>::type function,
|
Expression(typename UnaryFunction<A>::type function,
|
||||||
const Expression<A>& expression);
|
const Expression<A>& expression);
|
||||||
|
|
||||||
/// Construct a unary method expression
|
/// Construct a unary method expression
|
||||||
|
@ -125,7 +125,7 @@ public:
|
||||||
|
|
||||||
/// Construct a binary function expression
|
/// Construct a binary function expression
|
||||||
template<typename A1, typename A2>
|
template<typename A1, typename A2>
|
||||||
Expression(typename BinaryFunction<T, A1, A2>::type function,
|
Expression(typename BinaryFunction<A1, A2>::type function,
|
||||||
const Expression<A1>& expression1, const Expression<A2>& expression2);
|
const Expression<A1>& expression1, const Expression<A2>& expression2);
|
||||||
|
|
||||||
/// Construct a binary method expression
|
/// Construct a binary method expression
|
||||||
|
@ -139,7 +139,7 @@ public:
|
||||||
|
|
||||||
/// Construct a ternary function expression
|
/// Construct a ternary function expression
|
||||||
template<typename A1, typename A2, typename A3>
|
template<typename A1, typename A2, typename A3>
|
||||||
Expression(typename TernaryFunction<T, A1, A2, A3>::type function,
|
Expression(typename TernaryFunction<A1, A2, A3>::type function,
|
||||||
const Expression<A1>& expression1, const Expression<A2>& expression2,
|
const Expression<A1>& expression1, const Expression<A2>& expression2,
|
||||||
const Expression<A3>& expression3);
|
const Expression<A3>& expression3);
|
||||||
|
|
||||||
|
|
|
@ -327,7 +327,7 @@ TEST(ExpressionFactor, tree) {
|
||||||
boost::shared_ptr<GaussianFactor> gf2 = f2.linearize(values);
|
boost::shared_ptr<GaussianFactor> gf2 = f2.linearize(values);
|
||||||
EXPECT( assert_equal(*expected, *gf2, 1e-9));
|
EXPECT( assert_equal(*expected, *gf2, 1e-9));
|
||||||
|
|
||||||
TernaryFunction<Point2, Pose3, Point3, Cal3_S2>::type fff = project6;
|
Expression<Point2>::TernaryFunction<Pose3, Point3, Cal3_S2>::type fff = project6;
|
||||||
|
|
||||||
// Try ternary version
|
// Try ternary version
|
||||||
ExpressionFactor<Point2> f3(model, measured, project3(x, p, K));
|
ExpressionFactor<Point2> f3(model, measured, project3(x, p, K));
|
||||||
|
|
Loading…
Reference in New Issue