Formatting and some small problems
parent
cc997dd774
commit
d00aeb7e70
|
@ -10,7 +10,7 @@
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file Pose2SLAMExample.cpp
|
* @file Pose2SLAMExampleExpressions.cpp
|
||||||
* @brief Expressions version of Pose2SLAMExample.cpp
|
* @brief Expressions version of Pose2SLAMExample.cpp
|
||||||
* @date Oct 2, 2014
|
* @date Oct 2, 2014
|
||||||
* @author Frank Dellaert
|
* @author Frank Dellaert
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <gtsam/base/FastVector.h>
|
#include <gtsam/base/FastVector.h>
|
||||||
#include <gtsam/base/Matrix.h>
|
#include <gtsam/base/Matrix.h>
|
||||||
|
|
||||||
|
#include <boost/mpl/transform.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
class JacobianMap;
|
class JacobianMap;
|
||||||
|
@ -67,8 +69,7 @@ struct ConvertToDynamicRowsIf<false> {
|
||||||
* with Rows in 1..MaxSupportedStaticRows
|
* with Rows in 1..MaxSupportedStaticRows
|
||||||
*/
|
*/
|
||||||
template<int MaxSupportedStaticRows, int Cols>
|
template<int MaxSupportedStaticRows, int Cols>
|
||||||
struct ReverseADInterface: ReverseADInterface<MaxSupportedStaticRows - 1,
|
struct ReverseADInterface: ReverseADInterface<MaxSupportedStaticRows - 1, Cols> {
|
||||||
Cols> {
|
|
||||||
using ReverseADInterface<MaxSupportedStaticRows - 1, Cols>::_reverseAD;
|
using ReverseADInterface<MaxSupportedStaticRows - 1, Cols>::_reverseAD;
|
||||||
virtual void _reverseAD(
|
virtual void _reverseAD(
|
||||||
const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT,
|
const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT,
|
||||||
|
@ -92,19 +93,19 @@ template<typename Derived, int MaxSupportedStaticRows, int Cols>
|
||||||
struct ReverseADImplementor: ReverseADImplementor<Derived,
|
struct ReverseADImplementor: ReverseADImplementor<Derived,
|
||||||
MaxSupportedStaticRows - 1, Cols> {
|
MaxSupportedStaticRows - 1, Cols> {
|
||||||
private:
|
private:
|
||||||
using ReverseADImplementor<Derived,
|
using ReverseADImplementor<Derived, MaxSupportedStaticRows - 1, Cols>::_reverseAD;
|
||||||
MaxSupportedStaticRows - 1, Cols>::_reverseAD;
|
|
||||||
virtual void _reverseAD(
|
virtual void _reverseAD(
|
||||||
const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT,
|
const Eigen::Matrix<double, MaxSupportedStaticRows, Cols> & dFdT,
|
||||||
JacobianMap& jacobians) const {
|
JacobianMap& jacobians) const {
|
||||||
static_cast<const Derived *>(this)->reverseAD(dFdT, jacobians);
|
static_cast<const Derived *>(this)->reverseAD(dFdT, jacobians);
|
||||||
}
|
}
|
||||||
friend struct internal::ReverseADImplementor<Derived, MaxSupportedStaticRows + 1, Cols>;
|
friend struct internal::ReverseADImplementor<Derived,
|
||||||
|
MaxSupportedStaticRows + 1, Cols>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Derived, int Cols>
|
template<typename Derived, int Cols>
|
||||||
struct ReverseADImplementor<Derived, 0, Cols>
|
struct ReverseADImplementor<Derived, 0, Cols> : virtual internal::ReverseADInterface<
|
||||||
: virtual internal::ReverseADInterface<MaxVirtualStaticRows, Cols> {
|
MaxVirtualStaticRows, Cols> {
|
||||||
private:
|
private:
|
||||||
using internal::ReverseADInterface<MaxVirtualStaticRows, Cols>::_reverseAD;
|
using internal::ReverseADInterface<MaxVirtualStaticRows, Cols>::_reverseAD;
|
||||||
const Derived & derived() const {
|
const Derived & derived() const {
|
||||||
|
@ -131,8 +132,8 @@ private:
|
||||||
* It is implemented in the function-style ExpressionNode's nested Record class below.
|
* It is implemented in the function-style ExpressionNode's nested Record class below.
|
||||||
*/
|
*/
|
||||||
template<int Cols>
|
template<int Cols>
|
||||||
struct CallRecord: virtual private internal::ReverseADInterface<MaxVirtualStaticRows,
|
struct CallRecord: virtual private internal::ReverseADInterface<
|
||||||
Cols> {
|
MaxVirtualStaticRows, Cols> {
|
||||||
|
|
||||||
inline void print(const std::string& indent) const {
|
inline void print(const std::string& indent) const {
|
||||||
_print(indent);
|
_print(indent);
|
||||||
|
@ -150,8 +151,7 @@ struct CallRecord: virtual private internal::ReverseADInterface<MaxVirtualStatic
|
||||||
dFdT), jacobians);
|
dFdT), jacobians);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void reverseAD(const Matrix & dFdT,
|
inline void reverseAD(const Matrix & dFdT, JacobianMap& jacobians) const {
|
||||||
JacobianMap& jacobians) const {
|
|
||||||
_reverseAD(dFdT, jacobians);
|
_reverseAD(dFdT, jacobians);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +161,7 @@ struct CallRecord: virtual private internal::ReverseADInterface<MaxVirtualStatic
|
||||||
private:
|
private:
|
||||||
virtual void _print(const std::string& indent) const = 0;
|
virtual void _print(const std::string& indent) const = 0;
|
||||||
virtual void _startReverseAD(JacobianMap& jacobians) const = 0;
|
virtual void _startReverseAD(JacobianMap& jacobians) const = 0;
|
||||||
using internal::ReverseADInterface<MaxVirtualStaticRows,
|
using internal::ReverseADInterface<MaxVirtualStaticRows, Cols>::_reverseAD;
|
||||||
Cols>::_reverseAD;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -183,7 +182,7 @@ private:
|
||||||
virtual void _startReverseAD(JacobianMap& jacobians) const {
|
virtual void _startReverseAD(JacobianMap& jacobians) const {
|
||||||
derived().startReverseAD(jacobians);
|
derived().startReverseAD(jacobians);
|
||||||
}
|
}
|
||||||
template <typename D, int R, int C> friend class ReverseADImplementor;
|
template<typename D, int R, int C> friend struct ReverseADImplementor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
@ -28,19 +28,10 @@
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
// template meta-programming headers, TODO not all needed?
|
// template meta-programming headers
|
||||||
#include <boost/mpl/vector.hpp>
|
|
||||||
#include <boost/mpl/plus.hpp>
|
|
||||||
#include <boost/mpl/front.hpp>
|
|
||||||
#include <boost/mpl/pop_front.hpp>
|
|
||||||
#include <boost/mpl/fold.hpp>
|
#include <boost/mpl/fold.hpp>
|
||||||
#include <boost/mpl/empty_base.hpp>
|
|
||||||
#include <boost/mpl/placeholders.hpp>
|
|
||||||
#include <boost/mpl/transform.hpp>
|
|
||||||
#include <boost/mpl/at.hpp>
|
|
||||||
namespace MPL = boost::mpl::placeholders;
|
namespace MPL = boost::mpl::placeholders;
|
||||||
//
|
|
||||||
//#include <new> // for placement new
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class ExpressionFactorBinaryTest;
|
class ExpressionFactorBinaryTest;
|
||||||
|
@ -171,8 +162,9 @@ public:
|
||||||
content.ptr->startReverseAD(jacobians);
|
content.ptr->startReverseAD(jacobians);
|
||||||
}
|
}
|
||||||
// Either add to Jacobians (Leaf) or propagate (Function)
|
// Either add to Jacobians (Leaf) or propagate (Function)
|
||||||
template <typename DerivedMatrix>
|
template<typename DerivedMatrix>
|
||||||
void reverseAD(const Eigen::MatrixBase<DerivedMatrix> & dTdA, JacobianMap& jacobians) const {
|
void reverseAD(const Eigen::MatrixBase<DerivedMatrix> & dTdA,
|
||||||
|
JacobianMap& jacobians) const {
|
||||||
if (kind == Leaf)
|
if (kind == Leaf)
|
||||||
handleLeafCase(dTdA.eval(), jacobians, content.key);
|
handleLeafCase(dTdA.eval(), jacobians, content.key);
|
||||||
else if (kind == Function)
|
else if (kind == Function)
|
||||||
|
@ -435,7 +427,7 @@ struct FunctionalBase: ExpressionNode<T> {
|
||||||
}
|
}
|
||||||
void startReverseAD(JacobianMap& jacobians) const {
|
void startReverseAD(JacobianMap& jacobians) const {
|
||||||
}
|
}
|
||||||
template <typename SomeMatrix>
|
template<typename SomeMatrix>
|
||||||
void reverseAD(const SomeMatrix & dFdT, JacobianMap& jacobians) const {
|
void reverseAD(const SomeMatrix & dFdT, JacobianMap& jacobians) const {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -511,8 +503,9 @@ struct GenerateFunctionalNode: Argument<T, A, Base::N + 1>, Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given df/dT, multiply in dT/dA and continue reverse AD process
|
/// Given df/dT, multiply in dT/dA and continue reverse AD process
|
||||||
template <int Rows, int Cols>
|
template<int Rows, int Cols>
|
||||||
void reverseAD(const Eigen::Matrix<double, Rows, Cols> & dFdT, JacobianMap& jacobians) const {
|
void reverseAD(const Eigen::Matrix<double, Rows, Cols> & dFdT,
|
||||||
|
JacobianMap& jacobians) const {
|
||||||
Base::Record::reverseAD(dFdT, jacobians);
|
Base::Record::reverseAD(dFdT, jacobians);
|
||||||
This::trace.reverseAD(dFdT * This::dTdA, jacobians);
|
This::trace.reverseAD(dFdT * This::dTdA, jacobians);
|
||||||
}
|
}
|
||||||
|
@ -571,14 +564,14 @@ struct FunctionalNode {
|
||||||
|
|
||||||
/// Provide convenience access to Record storage and implement
|
/// Provide convenience access to Record storage and implement
|
||||||
/// the virtual function based interface of CallRecord using the CallRecordImplementor
|
/// the virtual function based interface of CallRecord using the CallRecordImplementor
|
||||||
struct Record:
|
struct Record: public internal::CallRecordImplementor<Record,
|
||||||
public internal::CallRecordImplementor<Record, traits::dimension<T>::value>,
|
traits::dimension<T>::value>, public Base::Record {
|
||||||
public Base::Record {
|
|
||||||
using Base::Record::print;
|
using Base::Record::print;
|
||||||
using Base::Record::startReverseAD;
|
using Base::Record::startReverseAD;
|
||||||
using Base::Record::reverseAD;
|
using Base::Record::reverseAD;
|
||||||
|
|
||||||
virtual ~Record(){}
|
virtual ~Record() {
|
||||||
|
}
|
||||||
|
|
||||||
/// Access Value
|
/// Access Value
|
||||||
template<class A, size_t N>
|
template<class A, size_t N>
|
||||||
|
|
|
@ -38,7 +38,6 @@ template<class T> struct Incomplete;
|
||||||
typedef mpl::vector<Pose3, Point3> MyTypes;
|
typedef mpl::vector<Pose3, Point3> MyTypes;
|
||||||
typedef FunctionalNode<Point2, MyTypes>::type Generated;
|
typedef FunctionalNode<Point2, MyTypes>::type Generated;
|
||||||
//Incomplete<Generated> incomplete;
|
//Incomplete<Generated> incomplete;
|
||||||
BOOST_MPL_ASSERT((boost::is_same< Matrix2, Generated::Record::Jacobian2T >));
|
|
||||||
|
|
||||||
// Try generating vectors of ExecutionTrace
|
// Try generating vectors of ExecutionTrace
|
||||||
typedef mpl::vector<ExecutionTrace<Pose3>, ExecutionTrace<Point3> > ExpectedTraces;
|
typedef mpl::vector<ExecutionTrace<Pose3>, ExecutionTrace<Point3> > ExpectedTraces;
|
||||||
|
|
Loading…
Reference in New Issue