File: timeCholesky.cpp

package info (click to toggle)
gtsam 4.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 46,108 kB
  • sloc: cpp: 127,191; python: 14,312; xml: 8,442; makefile: 252; sh: 119; ansic: 101
file content (60 lines) | stat: -rw-r--r-- 1,967 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ----------------------------------------------------------------------------

 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
 * Atlanta, Georgia 30332-0415
 * All Rights Reserved
 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)

 * See LICENSE for the license information

 * -------------------------------------------------------------------------- */

/**
 * @file    timeCholesky.cpp
 * @brief   time Cholesky factorization
 * @author  Frank Dellaert
 * @date    March 4, 2016
 */

#include <gtsam/base/cholesky.h>

#include <time.h>
#include <iostream>
#include <iomanip>      // std::setprecision

using namespace std;
using namespace gtsam;

//#define TERNARY

int main() {

  Matrix top = (Matrix(7,7) <<
                      4.0375,   3.4584,   3.5735,   2.4815,   2.1471,   2.7400,   2.2063,
                          0.,   4.7267,   3.8423,   2.3624,   2.8091,   2.9579,   2.5914,
                          0.,       0.,   5.1600,   2.0797,   3.4690,   3.2419,   2.9992,
                          0.,       0.,       0.,   1.8786,   1.0535,   1.4250,   1.3347,
                          0.,       0.,       0.,       0.,   3.0788,   2.6283,   2.3791,
                          0.,       0.,       0.,       0.,       0.,   2.9227,   2.4056,
                          0.,       0.,       0.,       0.,       0.,       0.,   2.5776).finished();

  Matrix ABC(100,100);
  ABC.topLeftCorner<7,7>() = top;
  cout << setprecision(3);

  size_t n = 100000;
  for (size_t nFrontal = 1; nFrontal <= 7; nFrontal++) {
    auto timeLog = clock();
    for (size_t i = 0; i < n; i++) {
      Matrix RSL(ABC);
      choleskyPartial(RSL, nFrontal);
    }
    auto timeLog2 = clock();
    auto seconds = (double)(timeLog2 - timeLog) / CLOCKS_PER_SEC;
    cout << "partialCholesky " << nFrontal << ": ";
    auto ms = ((double)seconds * 1000000 / n);
    cout << ms << " ms, " << ms/nFrontal << " ms/dim" << endl;
  }

  return 0;
}