Skip to content

Commit d5890a2

Browse files
committed
update all the tests
1 parent dc8b5e5 commit d5890a2

File tree

59 files changed

+555
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+555
-480
lines changed

gtsam/discrete/tests/testAlgebraicDecisionTree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void dot(const T&f, const string& filename) {
5454
}
5555

5656
/** I can't get this to work !
57-
class Mul: boost::function<double(const double&, const double&)> {
57+
class Mul: std::function<double(const double&, const double&)> {
5858
inline double operator()(const double& a, const double& b) {
5959
return a * b;
6060
}

gtsam/discrete/tests/testDecisionTree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ TEST(DT, conversion)
196196
map<string, Label> ordering;
197197
ordering[A] = X;
198198
ordering[B] = Y;
199-
boost::function<bool(const int&)> op = convert;
199+
std::function<bool(const int&)> op = convert;
200200
BDT f2(f1, ordering, op);
201201
// f1.print("f1");
202202
// f2.print("f2");

gtsam/geometry/tests/testCalibratedCamera.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
#include <gtsam/base/Testable.h>
2121
#include <gtsam/base/numericalDerivative.h>
2222

23-
#include <boost/bind/bind.hpp>
2423
#include <CppUnitLite/TestHarness.h>
2524

2625
#include <iostream>
2726

28-
using namespace boost::placeholders;
27+
using namespace std::placeholders;
2928
using namespace std;
3029
using namespace gtsam;
3130

@@ -54,8 +53,8 @@ TEST(CalibratedCamera, Create) {
5453
EXPECT(assert_equal(camera, CalibratedCamera::Create(kDefaultPose, actualH)));
5554

5655
// Check derivative
57-
boost::function<CalibratedCamera(Pose3)> f = //
58-
boost::bind(CalibratedCamera::Create, _1, boost::none);
56+
std::function<CalibratedCamera(Pose3)> f = //
57+
std::bind(CalibratedCamera::Create, std::placeholders::_1, boost::none);
5958
Matrix numericalH = numericalDerivative11<CalibratedCamera, Pose3>(f, kDefaultPose);
6059
EXPECT(assert_equal(numericalH, actualH, 1e-9));
6160
}

gtsam/geometry/tests/testEssentialMatrix.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
* @date December 17, 2013
66
*/
77

8-
#include <gtsam/geometry/EssentialMatrix.h>
9-
#include <gtsam/geometry/CalibratedCamera.h>
10-
#include <gtsam/base/numericalDerivative.h>
8+
#include <CppUnitLite/TestHarness.h>
119
#include <gtsam/base/Testable.h>
10+
#include <gtsam/base/numericalDerivative.h>
11+
#include <gtsam/geometry/CalibratedCamera.h>
12+
#include <gtsam/geometry/EssentialMatrix.h>
1213

13-
#include <boost/bind/bind.hpp>
14-
#include <CppUnitLite/TestHarness.h>
1514
#include <sstream>
1615

17-
using namespace boost::placeholders;
16+
using namespace std::placeholders;
1817
using namespace std;
1918
using namespace gtsam;
2019

@@ -42,15 +41,15 @@ TEST(EssentialMatrix, FromRotationAndDirection) {
4241
1e-8));
4342

4443
Matrix expectedH1 = numericalDerivative11<EssentialMatrix, Rot3>(
45-
boost::bind(EssentialMatrix::FromRotationAndDirection, _1, trueDirection, boost::none,
46-
boost::none),
44+
std::bind(EssentialMatrix::FromRotationAndDirection,
45+
std::placeholders::_1, trueDirection, boost::none, boost::none),
4746
trueRotation);
4847
EXPECT(assert_equal(expectedH1, actualH1, 1e-7));
4948

5049
Matrix expectedH2 = numericalDerivative11<EssentialMatrix, Unit3>(
51-
boost::bind(EssentialMatrix::FromRotationAndDirection, trueRotation, _1, boost::none,
52-
boost::none),
53-
trueDirection);
50+
std::bind(EssentialMatrix::FromRotationAndDirection, trueRotation,
51+
std::placeholders::_1, boost::none, boost::none),
52+
trueDirection);
5453
EXPECT(assert_equal(expectedH2, actualH2, 1e-7));
5554
}
5655

@@ -176,7 +175,7 @@ TEST (EssentialMatrix, FromPose3_a) {
176175
Pose3 pose(trueRotation, trueTranslation); // Pose between two cameras
177176
EXPECT(assert_equal(trueE, EssentialMatrix::FromPose3(pose, actualH), 1e-8));
178177
Matrix expectedH = numericalDerivative11<EssentialMatrix, Pose3>(
179-
boost::bind(EssentialMatrix::FromPose3, _1, boost::none), pose);
178+
std::bind(EssentialMatrix::FromPose3, std::placeholders::_1, boost::none), pose);
180179
EXPECT(assert_equal(expectedH, actualH, 1e-7));
181180
}
182181

@@ -189,7 +188,7 @@ TEST (EssentialMatrix, FromPose3_b) {
189188
Pose3 pose(c1Rc2, c1Tc2); // Pose between two cameras
190189
EXPECT(assert_equal(E, EssentialMatrix::FromPose3(pose, actualH), 1e-8));
191190
Matrix expectedH = numericalDerivative11<EssentialMatrix, Pose3>(
192-
boost::bind(EssentialMatrix::FromPose3, _1, boost::none), pose);
191+
std::bind(EssentialMatrix::FromPose3, std::placeholders::_1, boost::none), pose);
193192
EXPECT(assert_equal(expectedH, actualH, 1e-5));
194193
}
195194

gtsam/geometry/tests/testOrientedPlane3.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
#include <gtsam/base/numericalDerivative.h>
2222
#include <CppUnitLite/TestHarness.h>
2323
#include <boost/assign/std/vector.hpp>
24-
#include <boost/bind/bind.hpp>
2524

2625
using namespace boost::assign;
27-
using namespace boost::placeholders;
26+
using namespace std::placeholders;
2827
using namespace gtsam;
2928
using namespace std;
3029
using boost::none;
@@ -138,8 +137,9 @@ TEST(OrientedPlane3, errorVector) {
138137
Vector2(actual[0], actual[1])));
139138
EXPECT(assert_equal(plane1.distance() - plane2.distance(), actual[2]));
140139

141-
boost::function<Vector3(const OrientedPlane3&, const OrientedPlane3&)> f =
142-
boost::bind(&OrientedPlane3::errorVector, _1, _2, boost::none, boost::none);
140+
std::function<Vector3(const OrientedPlane3&, const OrientedPlane3&)> f =
141+
std::bind(&OrientedPlane3::errorVector, std::placeholders::_1,
142+
std::placeholders::_2, boost::none, boost::none);
143143
expectedH1 = numericalDerivative21(f, plane1, plane2);
144144
expectedH2 = numericalDerivative22(f, plane1, plane2);
145145
EXPECT(assert_equal(expectedH1, actualH1, 1e-5));
@@ -150,8 +150,8 @@ TEST(OrientedPlane3, errorVector) {
150150
TEST(OrientedPlane3, jacobian_retract) {
151151
OrientedPlane3 plane(-1, 0.1, 0.2, 5);
152152
Matrix33 H_actual;
153-
boost::function<OrientedPlane3(const Vector3&)> f =
154-
boost::bind(&OrientedPlane3::retract, plane, _1, boost::none);
153+
std::function<OrientedPlane3(const Vector3&)> f = std::bind(
154+
&OrientedPlane3::retract, plane, std::placeholders::_1, boost::none);
155155
{
156156
Vector3 v(-0.1, 0.2, 0.3);
157157
plane.retract(v, H_actual);

gtsam/geometry/tests/testPinholeCamera.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@
2222
#include <gtsam/base/Testable.h>
2323
#include <gtsam/base/numericalDerivative.h>
2424

25-
#include <boost/bind/bind.hpp>
2625
#include <CppUnitLite/TestHarness.h>
2726

2827
#include <cmath>
2928
#include <iostream>
3029

31-
using namespace boost::placeholders;
30+
using namespace std::placeholders;
3231
using namespace std;
3332
using namespace gtsam;
3433

@@ -66,8 +65,9 @@ TEST(PinholeCamera, Create) {
6665
EXPECT(assert_equal(camera, Camera::Create(pose,K, actualH1, actualH2)));
6766

6867
// Check derivative
69-
boost::function<Camera(Pose3,Cal3_S2)> f = //
70-
boost::bind(Camera::Create,_1,_2,boost::none,boost::none);
68+
std::function<Camera(Pose3, Cal3_S2)> f = //
69+
std::bind(Camera::Create, std::placeholders::_1, std::placeholders::_2,
70+
boost::none, boost::none);
7171
Matrix numericalH1 = numericalDerivative21<Camera,Pose3,Cal3_S2>(f,pose,K);
7272
EXPECT(assert_equal(numericalH1, actualH1, 1e-9));
7373
Matrix numericalH2 = numericalDerivative22<Camera,Pose3,Cal3_S2>(f,pose,K);
@@ -81,8 +81,8 @@ TEST(PinholeCamera, Pose) {
8181
EXPECT(assert_equal(pose, camera.getPose(actualH)));
8282

8383
// Check derivative
84-
boost::function<Pose3(Camera)> f = //
85-
boost::bind(&Camera::getPose,_1,boost::none);
84+
std::function<Pose3(Camera)> f = //
85+
std::bind(&Camera::getPose, std::placeholders::_1, boost::none);
8686
Matrix numericalH = numericalDerivative11<Pose3,Camera>(f,camera);
8787
EXPECT(assert_equal(numericalH, actualH, 1e-9));
8888
}

gtsam/geometry/tests/testPinholePose.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ TEST(PinholeCamera, Pose) {
6565
EXPECT(assert_equal(pose, camera.getPose(actualH)));
6666
6767
// Check derivative
68-
boost::function<Pose3(Camera)> f = //
69-
boost::bind(&Camera::getPose,_1,boost::none);
68+
std::function<Pose3(Camera)> f = //
69+
std::bind(&Camera::getPose,_1,boost::none);
7070
Matrix numericalH = numericalDerivative11<Pose3,Camera>(f,camera);
7171
EXPECT(assert_equal(numericalH, actualH, 1e-9));
7272
}

gtsam/geometry/tests/testPoint3.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* @brief Unit tests for Point3 class
1515
*/
1616

17-
#include <gtsam/geometry/Point3.h>
17+
#include <CppUnitLite/TestHarness.h>
1818
#include <gtsam/base/Testable.h>
1919
#include <gtsam/base/numericalDerivative.h>
20+
#include <gtsam/geometry/Point3.h>
2021

21-
#include <boost/bind/bind.hpp>
22-
#include <CppUnitLite/TestHarness.h>
22+
#include <boost/function.hpp>
2323

24-
using namespace boost::placeholders;
24+
using namespace std::placeholders;
2525
using namespace gtsam;
2626

2727
GTSAM_CONCEPT_TESTABLE_INST(Point3)
@@ -101,7 +101,7 @@ TEST( Point3, dot) {
101101

102102
// Use numerical derivatives to calculate the expected Jacobians
103103
Matrix H1, H2;
104-
boost::function<double(const Point3&, const Point3&)> f =
104+
std::function<double(const Point3&, const Point3&)> f =
105105
[](const Point3& p, const Point3& q) { return gtsam::dot(p, q); };
106106
{
107107
gtsam::dot(p, q, H1, H2);
@@ -123,8 +123,9 @@ TEST( Point3, dot) {
123123
/* ************************************************************************* */
124124
TEST(Point3, cross) {
125125
Matrix aH1, aH2;
126-
boost::function<Point3(const Point3&, const Point3&)> f =
127-
boost::bind(&gtsam::cross, _1, _2, boost::none, boost::none);
126+
std::function<Point3(const Point3&, const Point3&)> f =
127+
std::bind(&gtsam::cross, std::placeholders::_1, std::placeholders::_2,
128+
boost::none, boost::none);
128129
const Point3 omega(0, 1, 0), theta(4, 6, 8);
129130
cross(omega, theta, aH1, aH2);
130131
EXPECT(assert_equal(numericalDerivative21(f, omega, theta), aH1));
@@ -142,8 +143,9 @@ TEST( Point3, cross2) {
142143

143144
// Use numerical derivatives to calculate the expected Jacobians
144145
Matrix H1, H2;
145-
boost::function<Point3(const Point3&, const Point3&)> f = boost::bind(&gtsam::cross, _1, _2, //
146-
boost::none, boost::none);
146+
std::function<Point3(const Point3&, const Point3&)> f =
147+
std::bind(&gtsam::cross, std::placeholders::_1, std::placeholders::_2, //
148+
boost::none, boost::none);
147149
{
148150
gtsam::cross(p, q, H1, H2);
149151
EXPECT(assert_equal(numericalDerivative21<Point3,Point3>(f, p, q), H1, 1e-9));
@@ -163,7 +165,7 @@ TEST (Point3, normalize) {
163165
Point3 expected(point / sqrt(14.0));
164166
EXPECT(assert_equal(expected, normalize(point, actualH), 1e-8));
165167
Matrix expectedH = numericalDerivative11<Point3, Point3>(
166-
boost::bind(gtsam::normalize, _1, boost::none), point);
168+
std::bind(gtsam::normalize, std::placeholders::_1, boost::none), point);
167169
EXPECT(assert_equal(expectedH, actualH, 1e-8));
168170
}
169171

gtsam/geometry/tests/testPose3.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
#include <boost/assign/std/vector.hpp> // for operator +=
2424
using namespace boost::assign;
25-
#include <boost/bind/bind.hpp>
26-
using namespace boost::placeholders;
25+
using namespace std::placeholders;
2726

2827
#include <CppUnitLite/TestHarness.h>
2928
#include <cmath>
@@ -215,7 +214,7 @@ TEST(Pose3, translation) {
215214
EXPECT(assert_equal(Point3(3.5, -8.2, 4.2), T.translation(actualH), 1e-8));
216215

217216
Matrix numericalH = numericalDerivative11<Point3, Pose3>(
218-
boost::bind(&Pose3::translation, _1, boost::none), T);
217+
std::bind(&Pose3::translation, std::placeholders::_1, boost::none), T);
219218
EXPECT(assert_equal(numericalH, actualH, 1e-6));
220219
}
221220

@@ -226,7 +225,7 @@ TEST(Pose3, rotation) {
226225
EXPECT(assert_equal(R, T.rotation(actualH), 1e-8));
227226

228227
Matrix numericalH = numericalDerivative11<Rot3, Pose3>(
229-
boost::bind(&Pose3::rotation, _1, boost::none), T);
228+
std::bind(&Pose3::rotation, std::placeholders::_1, boost::none), T);
230229
EXPECT(assert_equal(numericalH, actualH, 1e-6));
231230
}
232231

@@ -1052,7 +1051,9 @@ TEST(Pose3, Create) {
10521051
Matrix63 actualH1, actualH2;
10531052
Pose3 actual = Pose3::Create(R, P2, actualH1, actualH2);
10541053
EXPECT(assert_equal(T, actual));
1055-
boost::function<Pose3(Rot3,Point3)> create = boost::bind(Pose3::Create,_1,_2,boost::none,boost::none);
1054+
std::function<Pose3(Rot3, Point3)> create =
1055+
std::bind(Pose3::Create, std::placeholders::_1, std::placeholders::_2,
1056+
boost::none, boost::none);
10561057
EXPECT(assert_equal(numericalDerivative21<Pose3,Rot3,Point3>(create, R, P2), actualH1, 1e-9));
10571058
EXPECT(assert_equal(numericalDerivative22<Pose3,Rot3,Point3>(create, R, P2), actualH2, 1e-9));
10581059
}

gtsam/geometry/tests/testSO3.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
* @author Frank Dellaert
1616
**/
1717

18-
#include <gtsam/geometry/SO3.h>
19-
18+
#include <CppUnitLite/TestHarness.h>
2019
#include <gtsam/base/Testable.h>
2120
#include <gtsam/base/testLie.h>
21+
#include <gtsam/geometry/SO3.h>
2222

23-
#include <boost/bind/bind.hpp>
24-
#include <CppUnitLite/TestHarness.h>
25-
26-
using namespace boost::placeholders;
23+
using namespace std::placeholders;
2724
using namespace std;
2825
using namespace gtsam;
2926

@@ -211,7 +208,7 @@ TEST(SO3, ExpmapDerivative) {
211208
TEST(SO3, ExpmapDerivative2) {
212209
const Vector3 theta(0.1, 0, 0.1);
213210
const Matrix Jexpected = numericalDerivative11<SO3, Vector3>(
214-
boost::bind(&SO3::Expmap, _1, boost::none), theta);
211+
std::bind(&SO3::Expmap, std::placeholders::_1, boost::none), theta);
215212

216213
CHECK(assert_equal(Jexpected, SO3::ExpmapDerivative(theta)));
217214
CHECK(assert_equal(Matrix3(Jexpected.transpose()),
@@ -222,7 +219,7 @@ TEST(SO3, ExpmapDerivative2) {
222219
TEST(SO3, ExpmapDerivative3) {
223220
const Vector3 theta(10, 20, 30);
224221
const Matrix Jexpected = numericalDerivative11<SO3, Vector3>(
225-
boost::bind(&SO3::Expmap, _1, boost::none), theta);
222+
std::bind(&SO3::Expmap, std::placeholders::_1, boost::none), theta);
226223

227224
CHECK(assert_equal(Jexpected, SO3::ExpmapDerivative(theta)));
228225
CHECK(assert_equal(Matrix3(Jexpected.transpose()),
@@ -277,7 +274,7 @@ TEST(SO3, ExpmapDerivative5) {
277274
TEST(SO3, ExpmapDerivative6) {
278275
const Vector3 thetahat(0.1, 0, 0.1);
279276
const Matrix Jexpected = numericalDerivative11<SO3, Vector3>(
280-
boost::bind(&SO3::Expmap, _1, boost::none), thetahat);
277+
std::bind(&SO3::Expmap, std::placeholders::_1, boost::none), thetahat);
281278
Matrix3 Jactual;
282279
SO3::Expmap(thetahat, Jactual);
283280
EXPECT(assert_equal(Jexpected, Jactual));
@@ -288,7 +285,7 @@ TEST(SO3, LogmapDerivative) {
288285
const Vector3 thetahat(0.1, 0, 0.1);
289286
const SO3 R = SO3::Expmap(thetahat); // some rotation
290287
const Matrix Jexpected = numericalDerivative11<Vector, SO3>(
291-
boost::bind(&SO3::Logmap, _1, boost::none), R);
288+
std::bind(&SO3::Logmap, std::placeholders::_1, boost::none), R);
292289
const Matrix3 Jactual = SO3::LogmapDerivative(thetahat);
293290
EXPECT(assert_equal(Jexpected, Jactual));
294291
}
@@ -298,7 +295,7 @@ TEST(SO3, JacobianLogmap) {
298295
const Vector3 thetahat(0.1, 0, 0.1);
299296
const SO3 R = SO3::Expmap(thetahat); // some rotation
300297
const Matrix Jexpected = numericalDerivative11<Vector, SO3>(
301-
boost::bind(&SO3::Logmap, _1, boost::none), R);
298+
std::bind(&SO3::Logmap, std::placeholders::_1, boost::none), R);
302299
Matrix3 Jactual;
303300
SO3::Logmap(R, Jactual);
304301
EXPECT(assert_equal(Jexpected, Jactual));
@@ -308,7 +305,7 @@ TEST(SO3, JacobianLogmap) {
308305
TEST(SO3, ApplyDexp) {
309306
Matrix aH1, aH2;
310307
for (bool nearZeroApprox : {true, false}) {
311-
boost::function<Vector3(const Vector3&, const Vector3&)> f =
308+
std::function<Vector3(const Vector3&, const Vector3&)> f =
312309
[=](const Vector3& omega, const Vector3& v) {
313310
return so3::DexpFunctor(omega, nearZeroApprox).applyDexp(v);
314311
};
@@ -331,7 +328,7 @@ TEST(SO3, ApplyDexp) {
331328
TEST(SO3, ApplyInvDexp) {
332329
Matrix aH1, aH2;
333330
for (bool nearZeroApprox : {true, false}) {
334-
boost::function<Vector3(const Vector3&, const Vector3&)> f =
331+
std::function<Vector3(const Vector3&, const Vector3&)> f =
335332
[=](const Vector3& omega, const Vector3& v) {
336333
return so3::DexpFunctor(omega, nearZeroApprox).applyInvDexp(v);
337334
};
@@ -357,7 +354,7 @@ TEST(SO3, vec) {
357354
Matrix actualH;
358355
const Vector9 actual = R2.vec(actualH);
359356
CHECK(assert_equal(expected, actual));
360-
boost::function<Vector9(const SO3&)> f = [](const SO3& Q) { return Q.vec(); };
357+
std::function<Vector9(const SO3&)> f = [](const SO3& Q) { return Q.vec(); };
361358
const Matrix numericalH = numericalDerivative11(f, R2, 1e-5);
362359
CHECK(assert_equal(numericalH, actualH));
363360
}
@@ -371,7 +368,7 @@ TEST(Matrix, compose) {
371368
Matrix actualH;
372369
const Matrix3 actual = so3::compose(M, R, actualH);
373370
CHECK(assert_equal(expected, actual));
374-
boost::function<Matrix3(const Matrix3&)> f = [R](const Matrix3& M) {
371+
std::function<Matrix3(const Matrix3&)> f = [R](const Matrix3& M) {
375372
return so3::compose(M, R);
376373
};
377374
Matrix numericalH = numericalDerivative11(f, M, 1e-2);

0 commit comments

Comments
 (0)