23 using namespace gtsam;
38 double timeCollect(
size_t p,
size_t m,
size_t n,
bool passDims,
size_t reps) {
46 vector<const Matrix *> matrices;
47 for (
size_t i=0;
i<
p;++
i) {
49 (*M) = Matrix::Identity(m,n);
50 matrices.push_back(M);
60 for (
size_t i=0;
i<reps; ++
i)
61 result =
collect(matrices, m, n);
63 for (
size_t i=0;
i<reps; ++
i)
68 elapsed = elapsedNode->secs();
72 for (
size_t i=0;
i<
p;++
i) {
90 for (
size_t i=0;
i<
m; ++
i)
91 for (
size_t j=0;
j<
n; ++
j)
96 for (
size_t i=0;
i<
m; ++
i)
104 for (
size_t i=0;
i<reps; ++
i)
109 elapsed = elapsedNode->secs();
126 for (
size_t i=0;
i<
m; ++
i)
127 for (
size_t j=0;
j<
n; ++
j)
132 for (
size_t i=0;
i<
n; ++
i)
140 for (
size_t i=0;
i<reps; ++
i)
145 elapsed = elapsedNode->secs();
163 size_t m = 100;
size_t n = 100;
165 for (
size_t i=0;
i<
m; ++
i)
166 for (
size_t j=0;
j<
n; ++
j)
175 for (
size_t i=0;
i<reps; ++
i)
176 for (
size_t j = 0; j<
n; ++
j)
182 elapsed = elapsedNode->secs();
212 -5, 0, 5, 0, 0, 0, -1,
213 00, -5, 0, 5, 0, 0, 1.5,
214 10, 0, 0, 0,-10, 0, 2,
215 00, 10, 0, 0, 0,-10, -1).finished();
222 for (
size_t i=0;
i<reps; ++
i) {
229 elapsed = elapsedNode->secs();
243 Matrix bigBase = Matrix::Zero(100, 100);
244 Matrix small = Matrix::Identity(5,5);
252 for (
size_t rep=0; rep<reps; ++rep)
253 for (
size_t i=0;
i<100;
i += 5)
254 for (
size_t j=0;
j<100;
j += 5)
259 elapsed = elapsedNode->secs();
265 int main(
int argc,
char ** argv) {
268 cout <<
"Starting Matrix::collect() Timing" << endl;
270 size_t p = 10;
size_t m = 10;
size_t n = 12;
size_t reps = 10000000;
271 double collect_time1 =
timeCollect(p, m, n,
false, reps);
272 double collect_time2 =
timeCollect(p, m, n,
true, reps);
273 cout <<
"Average Elapsed time for collect (no pass) [" << p <<
" (" << m <<
", " << n <<
") matrices] : " << collect_time1 << endl;
274 cout <<
"Average Elapsed time for collect (pass) [" << p <<
" (" << m <<
", " << n <<
") matrices] : " << collect_time2 << endl;
277 cout <<
"Starting Matrix::vector_scale(column) Timing" << endl;
278 size_t m1 = 400;
size_t n1 = 480;
size_t reps1 = 1000;
280 cout <<
"Elapsed time for vector_scale(column) [(" << m1 <<
", " << n1 <<
") matrix] : " << vsColumn_time << endl;
283 cout <<
"Starting Matrix::vector_scale(row) Timing" << endl;
285 cout <<
"Elapsed time for vector_scale(row) [(" << m1 <<
", " << n1 <<
") matrix] : " << vsRow_time << endl;
288 cout <<
"Starting column() Timing" << endl;
289 size_t reps2 = 2000000;
291 cout <<
"Time: " << column_time <<
" sec" << endl;
294 cout <<
"Starting householder_() Timing" << endl;
295 size_t reps_house = 5000000;
297 cout <<
"Elapsed time for householder_() : " << house_time <<
" sec" << endl;
300 cout <<
"Starting insertSub() Timing" << endl;
301 size_t reps_insert = 200000;
303 cout <<
"Elapsed time for insertSub() : " << insert_time <<
" sec" << endl;
#define tictoc_getNode(variable, label)
Matrix< RealScalar, Dynamic, Dynamic > M
double timeColumn(size_t reps)
int main(int argc, char **argv)
Matrix vector_scale(const Vector &v, const Matrix &A, bool inf_mask)
void householder_(Matrix &A, size_t k, bool copy_vectors)
double timeMatrixInsert(size_t reps)
double timeHouseholder(size_t reps)
void insertSub(Eigen::MatrixBase< Derived1 > &fullMatrix, const Eigen::MatrixBase< Derived2 > &subMatrix, size_t i, size_t j)
Matrix collect(const std::vector< const Matrix * > &matrices, size_t m, size_t n)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
const MATRIX::ConstColXpr column(const MATRIX &A, size_t j)
double timeVScaleColumn(size_t m, size_t n, size_t reps)
double timeVScaleRow(size_t m, size_t n, size_t reps)
double timeCollect(size_t p, size_t m, size_t n, bool passDims, size_t reps)