20 using namespace gtsam;
25 #define NUM_ITERATIONS 1000
28 ofstream
os(
"timeSchurFactors.csv");
31 template<
typename CAMERA>
37 static const int D = CAMERA::dimension;
40 vector <Matrix2D, Eigen::aligned_allocator<Matrix2D>> Fblocks;
41 for (
size_t i = 0;
i <
m;
i++) {
43 Fblocks.push_back((
i + 1) * Matrix::Ones(2,
D));
48 for (
size_t i = 0;
i <
m;
i++)
49 E.block < 2, 3 > (2 *
i, 0) = Matrix::Ones(2, 3);
55 const Vector b = Vector::Constant(2*
m,1);
61 for (
size_t i = 0;
i <
m;
i++)
62 xvalues.
insert(
i, Vector::Constant(
D,2));
73 #define TIME(label,factor,xx,yy) {\
74 for (size_t t = 0; t < N; t++) \
75 factor.multiplyHessianAdd(alpha, xx, yy);\
77 for (size_t t = 0; t < N; t++) {\
78 factor.multiplyHessianAdd(alpha, xx, yy);\
81 tictoc_getNode(timer, label)\
82 os << timer->secs()/NUM_ITERATIONS << ", ";\
86 TIME(Implicit, implicitFactor, xvalues, yvalues)
87 TIME(Jacobian, jf, xvalues, yvalues)
88 TIME(JacobianQR, jqr, xvalues, yvalues)
92 TIME(Hessian, hessianFactor, xvalues, yvalues)
103 for (
size_t i = 0;
i <
m;
i++)
106 double* xdata =
x.data();
110 TIME(RawImplicit, implicitFactor, xdata,
y.data())
111 TIME(RawJacobianQ, jf, xdata,
y.data())
112 TIME(RawJacobianQR, jqr, xdata,
y.data())
134 os <<
"RawImplicit,";
135 os <<
"RawJacobianQ,";
136 os <<
"RawJacobianQR,";
140 vector < size_t >
ms;
146 for (
size_t m = 2;
m <= 50;
m += 2)