Use new FixedRef type in tests
parent
dc40864a8f
commit
747071138e
|
|
@ -34,8 +34,8 @@ using namespace gtsam;
|
|||
|
||||
/* ************************************************************************* */
|
||||
template<class CAL>
|
||||
Point2 uncalibrate(const CAL& K, const Point2& p,
|
||||
boost::optional<Matrix25&> Dcal, boost::optional<Matrix2&> Dp) {
|
||||
Point2 uncalibrate(const CAL& K, const Point2& p, FixedRef<2, 5> Dcal,
|
||||
FixedRef<2, 2> Dp) {
|
||||
return K.uncalibrate(p, Dcal, Dp);
|
||||
}
|
||||
|
||||
|
|
@ -75,13 +75,13 @@ TEST(Expression, Leaves) {
|
|||
/* ************************************************************************* */
|
||||
// Unary(Leaf)
|
||||
namespace unary {
|
||||
Point2 f0(const Point3& p, boost::optional<Matrix23&> H) {
|
||||
Point2 f0(const Point3& p, FixedRef<2,3> H) {
|
||||
return Point2();
|
||||
}
|
||||
LieScalar f1(const Point3& p, boost::optional<Eigen::Matrix<double, 1, 3>&> H) {
|
||||
LieScalar f1(const Point3& p, FixedRef<1, 3> H) {
|
||||
return LieScalar(0.0);
|
||||
}
|
||||
double f2(const Point3& p, boost::optional<Eigen::Matrix<double, 1, 3>&> H) {
|
||||
double f2(const Point3& p, FixedRef<1, 3> H) {
|
||||
return 0.0;
|
||||
}
|
||||
Expression<Point3> p(1);
|
||||
|
|
@ -117,7 +117,7 @@ TEST(Expression, NullaryMethod) {
|
|||
// Check dims as map
|
||||
std::map<Key, int> map;
|
||||
norm.dims(map);
|
||||
LONGS_EQUAL(1,map.size());
|
||||
LONGS_EQUAL(1, map.size());
|
||||
|
||||
// Get value and Jacobians
|
||||
std::vector<Matrix> H(1);
|
||||
|
|
@ -133,9 +133,8 @@ TEST(Expression, NullaryMethod) {
|
|||
// Binary(Leaf,Leaf)
|
||||
namespace binary {
|
||||
// Create leaves
|
||||
double doubleF(const Pose3& pose, const Point3& point,
|
||||
boost::optional<Eigen::Matrix<double, 1, 6>&> H1,
|
||||
boost::optional<Eigen::Matrix<double, 1, 3>&> H2) {
|
||||
double doubleF(const Pose3& pose, //
|
||||
const Point3& point, FixedRef<1, 6> H1, FixedRef<1, 3> H2) {
|
||||
return 0.0;
|
||||
}
|
||||
Expression<Pose3> x(1);
|
||||
|
|
@ -244,8 +243,7 @@ TEST(Expression, compose3) {
|
|||
/* ************************************************************************* */
|
||||
// Test with ternary function
|
||||
Rot3 composeThree(const Rot3& R1, const Rot3& R2, const Rot3& R3,
|
||||
boost::optional<Matrix3&> H1, boost::optional<Matrix3&> H2,
|
||||
boost::optional<Matrix3&> H3) {
|
||||
FixedRef<3, 3> H1, FixedRef<3, 3> H2, FixedRef<3, 3> H3) {
|
||||
// return dummy derivatives (not correct, but that's ok for testing here)
|
||||
if (H1)
|
||||
*H1 = eye(3);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public:
|
|||
}
|
||||
|
||||
/// Given coefficients c, predict value for x
|
||||
double operator()(const Coefficients& c, boost::optional<Jacobian&> H) {
|
||||
double operator()(const Coefficients& c, FixedRef<1, N> H) {
|
||||
if (H)
|
||||
(*H) = H_;
|
||||
return H_ * c;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ TEST(ExpressionFactor, Unary) {
|
|||
|
||||
/* ************************************************************************* */
|
||||
static Point2 myUncal(const Cal3_S2& K, const Point2& p,
|
||||
boost::optional<Matrix25&> Dcal, boost::optional<Matrix2&> Dp) {
|
||||
FixedRef<2,5> Dcal, FixedRef<2,2> Dp) {
|
||||
return K.uncalibrate(p, Dcal, Dp);
|
||||
}
|
||||
|
||||
|
|
@ -392,8 +392,7 @@ TEST(ExpressionFactor, compose3) {
|
|||
/* ************************************************************************* */
|
||||
// Test compose with three arguments
|
||||
Rot3 composeThree(const Rot3& R1, const Rot3& R2, const Rot3& R3,
|
||||
boost::optional<Matrix3&> H1, boost::optional<Matrix3&> H2,
|
||||
boost::optional<Matrix3&> H3) {
|
||||
FixedRef<3, 3> H1, FixedRef<3, 3> H2, FixedRef<3, 3> H3) {
|
||||
// return dummy derivatives (not correct, but that's ok for testing here)
|
||||
if (H1)
|
||||
*H1 = eye(3);
|
||||
|
|
|
|||
|
|
@ -179,24 +179,24 @@ TEST(ExpressionFactor, InvokeDerivatives) {
|
|||
|
||||
// Let's assign it it to a boost function object
|
||||
// cast is needed because Pose3::transform_to is overloaded
|
||||
typedef boost::function<Point3(const Pose3&, const Point3&)> F;
|
||||
F f = static_cast<Point3 (Pose3::*)(
|
||||
const Point3&) const >(&Pose3::transform_to);
|
||||
|
||||
// Create arguments
|
||||
Pose3 pose;
|
||||
Point3 point;
|
||||
typedef boost::fusion::vector<Pose3, Point3> Arguments;
|
||||
Arguments args = boost::fusion::make_vector(pose, point);
|
||||
|
||||
// Create fused function (takes fusion vector) and call it
|
||||
boost::fusion::fused<F> g(f);
|
||||
Point3 actual = g(args);
|
||||
CHECK(assert_equal(point,actual));
|
||||
|
||||
// We can *immediately* do this using invoke
|
||||
Point3 actual2 = boost::fusion::invoke(f, args);
|
||||
CHECK(assert_equal(point,actual2));
|
||||
// typedef boost::function<Point3(const Pose3&, const Point3&)> F;
|
||||
// F f = static_cast<Point3 (Pose3::*)(
|
||||
// const Point3&) const >(&Pose3::transform_to);
|
||||
//
|
||||
// // Create arguments
|
||||
// Pose3 pose;
|
||||
// Point3 point;
|
||||
// typedef boost::fusion::vector<Pose3, Point3> Arguments;
|
||||
// Arguments args = boost::fusion::make_vector(pose, point);
|
||||
//
|
||||
// // Create fused function (takes fusion vector) and call it
|
||||
// boost::fusion::fused<F> g(f);
|
||||
// Point3 actual = g(args);
|
||||
// CHECK(assert_equal(point,actual));
|
||||
//
|
||||
// // We can *immediately* do this using invoke
|
||||
// Point3 actual2 = boost::fusion::invoke(f, args);
|
||||
// CHECK(assert_equal(point,actual2));
|
||||
|
||||
// Now, let's create the optional Jacobian arguments
|
||||
typedef Point3 T;
|
||||
|
|
@ -215,8 +215,8 @@ struct proxy {
|
|||
return pose.transform_to(point);
|
||||
}
|
||||
Point3 operator()(const Pose3& pose, const Point3& point,
|
||||
boost::optional<Matrix36&> Dpose,
|
||||
boost::optional<Matrix3&> Dpoint) const {
|
||||
FixedRef<3,6> Dpose,
|
||||
FixedRef<3,3> Dpoint) const {
|
||||
return pose.transform_to(point, Dpose, Dpoint);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue