diff --git a/.cproject b/.cproject
index b6b1aec87..5f9d5d349 100644
--- a/.cproject
+++ b/.cproject
@@ -2046,14 +2046,6 @@
true
true
-
- make
- -j4
- testCustomChartExpression.run
- true
- true
- true
-
make
-j5
diff --git a/gtsam/nonlinear/CallRecord.h b/gtsam/nonlinear/CallRecord.h
index 159a841e5..88ba0fb2d 100644
--- a/gtsam/nonlinear/CallRecord.h
+++ b/gtsam/nonlinear/CallRecord.h
@@ -20,18 +20,10 @@
#pragma once
-#include
-#include
-#include
-
+#include
#include
namespace gtsam {
-
-class JacobianMap;
-// forward declaration
-
-//-----------------------------------------------------------------------------
namespace internal {
/**
@@ -64,8 +56,6 @@ struct ConvertToVirtualFunctionSupportedMatrixType {
}
};
-} // namespace internal
-
/**
* The CallRecord is an abstract base class for the any class that stores
* the Jacobians of applying a function with respect to each of its arguments,
@@ -94,9 +84,8 @@ struct CallRecord {
inline void reverseAD2(const Eigen::MatrixBase & dFdT,
JacobianMap& jacobians) const {
_reverseAD3(
- internal::ConvertToVirtualFunctionSupportedMatrixType<
- (Derived::RowsAtCompileTime > 5)>::convert(dFdT),
- jacobians);
+ ConvertToVirtualFunctionSupportedMatrixType<
+ (Derived::RowsAtCompileTime > 5)>::convert(dFdT), jacobians);
}
// This overload supports matrices with both rows and columns dynamically sized.
@@ -140,7 +129,6 @@ private:
*/
const int CallRecordMaxVirtualStaticRows = 5;
-namespace internal {
/**
* The CallRecordImplementor implements the CallRecord interface for a Derived class by
* delegating to its corresponding (templated) non-virtual methods.
@@ -193,5 +181,4 @@ private:
};
} // namespace internal
-
} // gtsam
diff --git a/gtsam/nonlinear/ExecutionTrace.h b/gtsam/nonlinear/ExecutionTrace.h
index 292ad7719..ca7d78d81 100644
--- a/gtsam/nonlinear/ExecutionTrace.h
+++ b/gtsam/nonlinear/ExecutionTrace.h
@@ -27,6 +27,7 @@
#include
namespace gtsam {
+namespace internal {
template struct CallRecord;
@@ -36,8 +37,6 @@ template struct CallRecord;
static const unsigned TraceAlignment = 16;
typedef boost::aligned_storage<1, TraceAlignment>::type ExecutionTraceStorage;
-namespace internal {
-
template
struct UseBlockIf {
static void addToJacobian(const Eigen::MatrixBase& dTdA,
@@ -56,13 +55,12 @@ struct UseBlockIf {
jacobians(key) += dTdA;
}
};
-}
/// Handle Leaf Case: reverse AD ends here, by writing a matrix into Jacobians
template
void handleLeafCase(const Eigen::MatrixBase& dTdA,
JacobianMap& jacobians, Key key) {
- internal::UseBlockIf<
+ UseBlockIf<
Derived::RowsAtCompileTime != Eigen::Dynamic
&& Derived::ColsAtCompileTime != Eigen::Dynamic, Derived>::addToJacobian(
dTdA, jacobians, key);
@@ -164,4 +162,5 @@ public:
typedef ExecutionTrace type;
};
+} // namespace internal
} // namespace gtsam
diff --git a/gtsam/nonlinear/Expression-inl.h b/gtsam/nonlinear/Expression-inl.h
index 15ef269f2..3ab0bfe4d 100644
--- a/gtsam/nonlinear/Expression-inl.h
+++ b/gtsam/nonlinear/Expression-inl.h
@@ -36,25 +36,25 @@ void Expression::print(const std::string& s) const {
// Construct a constant expression
template
Expression::Expression(const T& value) :
- root_(new ConstantExpression(value)) {
+ root_(new internal::ConstantExpression(value)) {
}
// Construct a leaf expression, with Key
template
Expression::Expression(const Key& key) :
- root_(new LeafExpression(key)) {
+ root_(new internal::LeafExpression(key)) {
}
// Construct a leaf expression, with Symbol
template
Expression::Expression(const Symbol& symbol) :
- root_(new LeafExpression(symbol)) {
+ root_(new internal::LeafExpression(symbol)) {
}
// Construct a leaf expression, creating Symbol
template
Expression::Expression(unsigned char c, size_t j) :
- root_(new LeafExpression(Symbol(c, j))) {
+ root_(new internal::LeafExpression(Symbol(c, j))) {
}
/// Construct a nullary method expression
@@ -62,7 +62,9 @@ template
template
Expression::Expression(const Expression& expression,
T (A::*method)(typename MakeOptionalJacobian::type) const) :
- root_(new UnaryExpression(boost::bind(method, _1, _2), expression)) {
+ root_(
+ new internal::UnaryExpression(boost::bind(method, _1, _2),
+ expression)) {
}
/// Construct a unary function expression
@@ -70,7 +72,7 @@ template
template
Expression::Expression(typename UnaryFunction::type function,
const Expression& expression) :
- root_(new UnaryExpression(function, expression)) {
+ root_(new internal::UnaryExpression(function, expression)) {
}
/// Construct a unary method expression
@@ -81,8 +83,8 @@ Expression::Expression(const Expression& expression1,
typename MakeOptionalJacobian::type) const,
const Expression& expression2) :
root_(
- new BinaryExpression(boost::bind(method, _1, _2, _3, _4),
- expression1, expression2)) {
+ new internal::BinaryExpression(
+ boost::bind(method, _1, _2, _3, _4), expression1, expression2)) {
}
/// Construct a binary function expression
@@ -90,7 +92,9 @@ template
template
Expression::Expression(typename BinaryFunction::type function,
const Expression& expression1, const Expression& expression2) :
- root_(new BinaryExpression(function, expression1, expression2)) {
+ root_(
+ new internal::BinaryExpression(function, expression1,
+ expression2)) {
}
/// Construct a binary method expression
@@ -103,7 +107,7 @@ Expression::Expression(const Expression& expression1,
typename MakeOptionalJacobian::type) const,
const Expression& expression2, const Expression& expression3) :
root_(
- new TernaryExpression(
+ new internal::TernaryExpression(
boost::bind(method, _1, _2, _3, _4, _5, _6), expression1,
expression2, expression3)) {
}
@@ -115,13 +119,13 @@ Expression::Expression(typename TernaryFunction::type function,
const Expression& expression1, const Expression& expression2,
const Expression& expression3) :
root_(
- new TernaryExpression(function, expression1, expression2,
- expression3)) {
+ new internal::TernaryExpression(function, expression1,
+ expression2, expression3)) {
}
/// Return root
template
-const boost::shared_ptr >& Expression::root() const {
+const boost::shared_ptr >& Expression::root() const {
return root_;
}
@@ -186,10 +190,10 @@ T Expression::value(const Values& values, const FastVector& keys,
}
template
-T Expression::traceExecution(const Values& values, ExecutionTrace& trace,
- void* traceStorage) const {
+T Expression::traceExecution(const Values& values,
+ internal::ExecutionTrace& trace, void* traceStorage) const {
return root_->traceExecution(values, trace,
- static_cast(traceStorage));
+ static_cast(traceStorage));
}
template
@@ -205,12 +209,12 @@ T Expression::value(const Values& values, JacobianMap& jacobians) const {
// allocated on Visual Studio. For more information see the issue below
// https://bitbucket.org/gtborg/gtsam/issue/178/vlas-unsupported-in-visual-studio
#ifdef _MSC_VER
- ExecutionTraceStorage* traceStorage = new ExecutionTraceStorage[size];
+ internal::ExecutionTraceStorage* traceStorage = new internal::ExecutionTraceStorage[size];
#else
- ExecutionTraceStorage traceStorage[size];
+ internal::ExecutionTraceStorage traceStorage[size];
#endif
- ExecutionTrace trace;
+ internal::ExecutionTrace trace;
T value(this->traceExecution(values, trace, traceStorage));
trace.startReverseAD1(jacobians);
@@ -226,7 +230,7 @@ typename Expression::KeysAndDims Expression::keysAndDims() const {
std::map map;
dims(map);
size_t n = map.size();
- KeysAndDims pair = std::make_pair(FastVector < Key > (n), FastVector(n));
+ KeysAndDims pair = std::make_pair(FastVector(n), FastVector(n));
boost::copy(map | boost::adaptors::map_keys, pair.first.begin());
boost::copy(map | boost::adaptors::map_values, pair.second.begin());
return pair;
diff --git a/gtsam/nonlinear/Expression.h b/gtsam/nonlinear/Expression.h
index f81a17c96..a7a3326c3 100644
--- a/gtsam/nonlinear/Expression.h
+++ b/gtsam/nonlinear/Expression.h
@@ -32,9 +32,12 @@ namespace gtsam {
// Forward declares
class Values;
+template class ExpressionFactor;
+
+namespace internal {
template class ExecutionTrace;
template class ExpressionNode;
-template class ExpressionFactor;
+}
/**
* Expression class that supports automatic differentiation
@@ -50,7 +53,7 @@ public:
private:
// Paul's trick shared pointer, polymorphic root of entire expression tree
- boost::shared_ptr > root_;
+ boost::shared_ptr > root_;
public:
@@ -131,7 +134,7 @@ public:
const Expression& expression3);
/// Return root
- const boost::shared_ptr >& root() const;
+ const boost::shared_ptr >& root() const;
// Return size needed for memory buffer in traceExecution
size_t traceSize() const;
@@ -170,7 +173,7 @@ private:
const FastVector& dims, std::vector& H) const;
/// trace execution, very unsafe
- T traceExecution(const Values& values, ExecutionTrace& trace,
+ T traceExecution(const Values& values, internal::ExecutionTrace& trace,
void* traceStorage) const;
/**
diff --git a/gtsam/nonlinear/ExpressionNode.h b/gtsam/nonlinear/ExpressionNode.h
index 26585ce4d..1cbfd488c 100644
--- a/gtsam/nonlinear/ExpressionNode.h
+++ b/gtsam/nonlinear/ExpressionNode.h
@@ -35,6 +35,7 @@ class ExpressionFactorBinaryTest;
// Forward declare for testing
namespace gtsam {
+namespace internal {
template
T & upAlign(T & value, unsigned requiredAlignment = TraceAlignment) {
@@ -412,8 +413,8 @@ struct FunctionalNode {
/// Provide convenience access to Record storage and implement
/// the virtual function based interface of CallRecord using the CallRecordImplementor
- struct Record: public internal::CallRecordImplementor::dimension>, public Base::Record {
+ struct Record: public CallRecordImplementor::dimension>,
+ public Base::Record {
using Base::Record::print;
using Base::Record::startReverseAD4;
using Base::Record::reverseAD4;
@@ -497,8 +498,8 @@ public:
// Inner Record Class
// The reason we inherit from JacobianTrace is because we can then
// case to this unique signature to retrieve the value/trace at any level
- struct Record: public internal::CallRecordImplementor::dimension>, JacobianTrace {
+ struct Record: public CallRecordImplementor::dimension>,
+ JacobianTrace {
typedef T return_type;
typedef JacobianTrace This;
@@ -600,7 +601,7 @@ public:
private:
- typedef typename Expression::template BinaryFunction::type Function;
+ typedef typename Expression::template BinaryFunction::type Function;
Function function_;
/// Constructor with a ternary function f, and three input arguments
@@ -650,7 +651,7 @@ class TernaryExpression: public FunctionalNode
private:
- typedef typename Expression::template TernaryFunction::type Function;
+ typedef typename Expression::template TernaryFunction::type Function;
Function function_;
/// Constructor with a ternary function f, and three input arguments
@@ -693,4 +694,6 @@ public:
};
-} // namespace gtsam
+}
+ // namespace internal
+}// namespace gtsam
diff --git a/gtsam/nonlinear/expressionTesting.h b/gtsam/nonlinear/expressionTesting.h
index ab6703f3a..92fff9e04 100644
--- a/gtsam/nonlinear/expressionTesting.h
+++ b/gtsam/nonlinear/expressionTesting.h
@@ -88,7 +88,7 @@ void testFactorJacobians(TestResult& result_, const std::string& name_,
// Check cast result and then equality
CHECK(actual);
- EXPECT( assert_equal(expected, *actual, tolerance));
+ EXPECT(assert_equal(expected, *actual, tolerance));
}
}
@@ -112,7 +112,7 @@ void testExpressionJacobians(TestResult& result_, const std::string& name_,
expression.value(values), expression);
testFactorJacobians(result_, name_, f, values, nd_step, tolerance);
}
-}
+} // namespace internal
} // namespace gtsam
/// \brief Check the Jacobians produced by an expression against finite differences.
diff --git a/gtsam/nonlinear/tests/testCallRecord.cpp b/gtsam/nonlinear/tests/testCallRecord.cpp
index 483b5ffa9..376ef56e4 100644
--- a/gtsam/nonlinear/tests/testCallRecord.cpp
+++ b/gtsam/nonlinear/tests/testCallRecord.cpp
@@ -32,7 +32,7 @@ static const int Cols = 3;
int dynamicIfAboveMax(int i){
- if(i > CallRecordMaxVirtualStaticRows){
+ if(i > internal::CallRecordMaxVirtualStaticRows){
return Eigen::Dynamic;
}
else return i;
diff --git a/gtsam/nonlinear/tests/testExecutionTrace.cpp b/gtsam/nonlinear/tests/testExecutionTrace.cpp
index cb4dfd2e7..5d0f33966 100644
--- a/gtsam/nonlinear/tests/testExecutionTrace.cpp
+++ b/gtsam/nonlinear/tests/testExecutionTrace.cpp
@@ -27,7 +27,7 @@ using namespace gtsam;
/* ************************************************************************* */
// Constant
TEST(ExecutionTrace, construct) {
- ExecutionTrace trace;
+ internal::ExecutionTrace trace;
}
/* ************************************************************************* */
diff --git a/gtsam/nonlinear/tests/testExpression.cpp b/gtsam/nonlinear/tests/testExpression.cpp
index 84f180609..c47079db3 100644
--- a/gtsam/nonlinear/tests/testExpression.cpp
+++ b/gtsam/nonlinear/tests/testExpression.cpp
@@ -165,7 +165,7 @@ TEST(Expression, BinaryDimensions) {
/* ************************************************************************* */
// dimensions
TEST(Expression, BinaryTraceSize) {
- typedef BinaryExpression Binary;
+ typedef internal::BinaryExpression Binary;
size_t expectedTraceSize = sizeof(Binary::Record);
EXPECT_LONGS_EQUAL(expectedTraceSize, binary::p_cam.traceSize());
}
@@ -196,9 +196,9 @@ TEST(Expression, TreeDimensions) {
/* ************************************************************************* */
// TraceSize
TEST(Expression, TreeTraceSize) {
- typedef UnaryExpression Unary;
- typedef BinaryExpression Binary1;
- typedef BinaryExpression Binary2;
+ typedef internal::UnaryExpression Unary;
+ typedef internal::BinaryExpression Binary1;
+ typedef internal::BinaryExpression Binary2;
size_t expectedTraceSize = sizeof(Unary::Record) + sizeof(Binary1::Record)
+ sizeof(Binary2::Record);
EXPECT_LONGS_EQUAL(expectedTraceSize, tree::uv_hat.traceSize());
diff --git a/gtsam/nonlinear/tests/testExpressionFactor.cpp b/gtsam/nonlinear/tests/testExpressionFactor.cpp
index 900293261..ead6e0176 100644
--- a/gtsam/nonlinear/tests/testExpressionFactor.cpp
+++ b/gtsam/nonlinear/tests/testExpressionFactor.cpp
@@ -169,7 +169,7 @@ static Point2 myUncal(const Cal3_S2& K, const Point2& p,
// Binary(Leaf,Leaf)
TEST(ExpressionFactor, Binary) {
- typedef BinaryExpression Binary;
+ typedef internal::BinaryExpression Binary;
Cal3_S2_ K_(1);
Point2_ p_(2);
@@ -184,10 +184,10 @@ TEST(ExpressionFactor, Binary) {
EXPECT_LONGS_EQUAL(8, sizeof(double));
EXPECT_LONGS_EQUAL(16, sizeof(Point2));
EXPECT_LONGS_EQUAL(40, sizeof(Cal3_S2));
- EXPECT_LONGS_EQUAL(16, sizeof(ExecutionTrace));
- EXPECT_LONGS_EQUAL(16, sizeof(ExecutionTrace));
- EXPECT_LONGS_EQUAL(2*5*8, sizeof(Jacobian::type));
- EXPECT_LONGS_EQUAL(2*2*8, sizeof(Jacobian::type));
+ EXPECT_LONGS_EQUAL(16, sizeof(internal::ExecutionTrace));
+ EXPECT_LONGS_EQUAL(16, sizeof(internal::ExecutionTrace));
+ EXPECT_LONGS_EQUAL(2*5*8, sizeof(internal::Jacobian::type));
+ EXPECT_LONGS_EQUAL(2*2*8, sizeof(internal::Jacobian::type));
size_t expectedRecordSize = 16 + 16 + 40 + 2 * 16 + 80 + 32;
EXPECT_LONGS_EQUAL(expectedRecordSize + 8, sizeof(Binary::Record));
@@ -197,8 +197,8 @@ TEST(ExpressionFactor, Binary) {
EXPECT_LONGS_EQUAL(expectedRecordSize + 8, size);
// Use Variable Length Array, allocated on stack by gcc
// Note unclear for Clang: http://clang.llvm.org/compatibility.html#vla
- ExecutionTraceStorage traceStorage[size];
- ExecutionTrace trace;
+ internal::ExecutionTraceStorage traceStorage[size];
+ internal::ExecutionTrace trace;
Point2 value = binary.traceExecution(values, trace, traceStorage);
EXPECT(assert_equal(Point2(),value, 1e-9));
// trace.print();
@@ -250,8 +250,8 @@ TEST(ExpressionFactor, Shallow) {
LONGS_EQUAL(3,dims[1]);
// traceExecution of shallow tree
- typedef UnaryExpression Unary;
- typedef BinaryExpression Binary;
+ typedef internal::UnaryExpression Unary;
+ typedef internal::BinaryExpression Binary;
size_t expectedTraceSize = sizeof(Unary::Record) + sizeof(Binary::Record);
EXPECT_LONGS_EQUAL(112, sizeof(Unary::Record));
#ifdef GTSAM_USE_QUATERNIONS
@@ -264,8 +264,8 @@ TEST(ExpressionFactor, Shallow) {
size_t size = expression.traceSize();
CHECK(size);
EXPECT_LONGS_EQUAL(expectedTraceSize, size);
- ExecutionTraceStorage traceStorage[size];
- ExecutionTrace trace;
+ internal::ExecutionTraceStorage traceStorage[size];
+ internal::ExecutionTrace trace;
Point2 value = expression.traceExecution(values, trace, traceStorage);
EXPECT(assert_equal(Point2(),value, 1e-9));
// trace.print();
diff --git a/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp b/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp
index 7c2f9d9b9..211d07329 100644
--- a/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp
+++ b/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp
@@ -26,6 +26,7 @@
using namespace std;
using namespace gtsam;
+using namespace gtsam::internal;
/* ************************************************************************* */
namespace mpl = boost::mpl;